Imported Upstream version 1.8.8
[platform/upstream/doxygen.git] / src / languages.py
1 #
2 # This file is an aid to generated the Languages rules file.
3 # usage:
4 #   python languages.py > ..\winbuild\Languages.rules
5 #
6 import os
7 import re
8
9 files = [f for f in os.listdir('.') if re.match(r'translator_[a-z][a-z]\.h', f)]
10 new_list = []
11 for f in files:
12     new_list.append([f,(os.path.splitext(f)[0]).replace("translator_","").upper()])
13
14 #
15 # generating file is lang_cfg.py
16 # the rules file has to output lang_cfg.h
17 #
18 print("""\
19 <?xml version="1.0" encoding="utf-8"?>
20 <VisualStudioToolFile
21         Name="languages"
22         Version="8.00"
23         >
24         <Rules>
25                 <CustomBuildRule
26                         Name="Languages"
27                         DisplayName="Settings"
28                         CommandLine="python $(InputPath) [AllOptions] [AdditionalOptions] &gt; $(InpDir)/$(InputName).h"
29                         Outputs="$(IntDir)/$(InputName).h"
30                         FileExtensions="*.py"
31                         AdditionalDependencies=""
32                         ExecutionDescription="Executing languages ..."
33                         ShowOnlyRuleProperties="false"
34                         >
35                         <Properties>
36                                <EnumProperty
37                                        Name="EnglishOnly"
38                                        DisplayName="Use English Only"
39                                        Description="Use English Only"
40                                        DefaultValue="0"
41                                >
42                                        <Values>
43                                                <EnumValue
44                                                Value="0"
45                                                Switch=""
46                                                DisplayName="Don't use English Only"
47                                                />
48                                                <EnumValue
49                                                Value="1"
50                                                Switch="ENONLY"
51                                                DisplayName="Use English Only"
52                                                />
53                                        </Values>
54                                </EnumProperty>
55 """)
56 #
57 # generate loop, English is mandatory (so cannot be chosen)
58 #
59 for f in new_list:
60     if (f[1] != "EN"):
61         # search for the language description
62         fil = open(f[0], 'r')
63         tmp = ""
64         for line in fil:
65           if "idLanguage" in line:
66              tmp = line
67              if "}" in line:
68                break
69           elif (tmp != ""):
70              tmp += line
71              if "}" in line:
72                break
73     
74         tmp = tmp.replace("\n","")
75         l = re.sub('[^"]*"([^"]*)".*','\\1',tmp)
76         l1 = l.replace("-","")
77         # capatalize first letter
78         l = l.title()
79         print("""\
80                                    <EnumProperty
81                                            Name="%s"
82                                            DisplayName="Use %s"
83                                            Description="Use %s"
84                                            DefaultValue="1"
85                                    >
86                                            <Values>
87                                                    <EnumValue
88                                                    Value="0"
89                                                    Switch=""
90                                                    DisplayName="Don't use %s"
91                                                    />
92                                                    <EnumValue
93                                                    Value="1"
94                                                    Switch="%s"
95                                                    DisplayName="Use %s"
96                                                    />
97                                            </Values>
98                                    </EnumProperty>
99         """ % (l1, l, l, l, f[1], l))
100
101 print("""\
102                         </Properties>
103                 </CustomBuildRule>
104         </Rules>
105 </VisualStudioToolFile>
106 """)