]>
git.saurik.com Git - wxWidgets.git/blob - misc/languages/genlang.py
4 # Generates wxLanguage enum (to be cut&pasted to include/wx/intl.h)
5 # and convertion tables (ditto to src/common/intl.cpp)
12 f
= open('langtabl.txt')
13 for i
in f
.readlines():
15 table
.append((ispl
[0], ispl
[1], ispl
[2], ispl
[3], ispl
[4], string
.join(ispl
[5:])))
21 f
= open('_wxlang.h', 'wt')
24 // --- --- --- generated code begins here --- --- ---
26 // This enum is generated by misc/languages/genlang.py
27 // When making changes, please put them into misc/languages/langtabl.txt
30 // user's default/preffered language as got from OS:
32 // unknown language, if wxLocale::GetSystemLanguage fails:
37 f
.write(' %s,\n' % i
[0])
39 // for custom, user-defined languages:
40 wxLANGUAGE_USER_DEFINED
43 // --- --- --- generated code ends here --- --- ---
50 f
= open('_wxlang.tex', 'wt')
53 %% --- --- --- generated code begins here --- --- ---
55 %% This enum is generated by misc/languages/genlang.py
56 %% When making changes, please put them into misc/languages/langtabl.txt
57 \\begin{itemize}\\itemsep=0pt
58 \\item wxLANGUAGE_DEFAULT -- user's default language as obtained from the operating system
59 \\item wxLANGUAGE_UNKNOWN -- returned by \\helpref{GetSystemLanguage}{wxlocalegetsystemlanguage}
60 if it fails to detect the default language
61 \\item wxLANGUAGE_USER_DEFINED -- user defined languages' integer identifiers should start from
65 f
.write('\\item %s\n' % (i
[0].replace('_','\\_')))
66 f
.write("""\\end{itemize}
68 %% --- --- --- generated code ends here --- --- ---
85 if ican
== '"-"': ican
= '""'
87 if ilang
== '-': ilang
= '0'
89 if isublang
== '-': isublang
= '0'
91 ilayout
= "wxLayout_LeftToRight"
93 ilayout
= "wxLayout_RightToLeft"
95 print "ERROR: Invalid value for the layout direction";
96 lngtable
+= ' LNG(%-38s %-7s, %-15s, %-34s, %s, %s)\n' % \
97 ((i
[0]+','), ican
, ilang
, isublang
, ilayout
, i
[5])
98 if ilang
not in all_langs
: all_langs
.append(ilang
)
99 if isublang
not in all_sublangs
: all_sublangs
.append(isublang
)
103 ifdefs
+= '#ifndef %s\n#define %s (0)\n#endif\n' % (s
, s
)
104 for s
in all_sublangs
:
105 if s
!= '0' and s
!= 'SUBLANG_DEFAULT':
106 ifdefs
+= '#ifndef %s\n#define %s SUBLANG_DEFAULT\n#endif\n' % (s
, s
)
108 f
= open('_wxlang.cpp', 'wt')
110 // --- --- --- generated code begins here --- --- ---
112 // This table is generated by misc/languages/genlang.py
113 // When making changes, please put them into misc/languages/langtabl.txt
117 #define SETWINLANG(info,lang,sublang)
121 #define SETWINLANG(info,lang,sublang) \\
122 info.WinLang = lang, info.WinSublang = sublang;
128 #define LNG(wxlang, canonical, winlang, winsublang, layout, desc) \\
129 info.Language = wxlang; \\
130 info.CanonicalName = wxT(canonical); \\
131 info.LayoutDirection = layout; \\
132 info.Description = wxT(desc); \\
133 SETWINLANG(info, winlang, winsublang) \\
136 void wxLocale::InitLanguagesDB()
139 wxStringTokenizer tkn;
145 // --- --- --- generated code ends here --- --- ---
147 """ % (ifdefs
, lngtable
))