]>
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:
38 if i
[0] not in knownLangs
:
39 f
.write(' %s,\n' % i
[0])
40 knownLangs
.append(i
[0])
42 // for custom, user-defined languages:
43 wxLANGUAGE_USER_DEFINED
46 // --- --- --- generated code ends here --- --- ---
53 f
= open('_wxlang.tex', 'wt')
56 %% --- --- --- generated code begins here --- --- ---
58 %% This enum is generated by misc/languages/genlang.py
59 %% When making changes, please put them into misc/languages/langtabl.txt
60 \\begin{twocollist}\\itemsep=0pt
61 \\twocolitem{wxLANGUAGE\\_DEFAULT}{user's default language as obtained from the operating system}
62 \\twocolitem{wxLANGUAGE\\_UNKNOWN}{returned by \\helpref{GetSystemLanguage}{wxlocalegetsystemlanguage} if it fails to detect the default language}
63 \\twocolitem{wxLANGUAGE\\_USER\\_DEFINED}{user defined languages' integer identifiers should start from this}
67 if i
[0] not in knownLangs
:
68 f
.write('\\twocolitem{%s}{}\n' % (i
[0].replace('_','\\_')))
69 knownLangs
.append(i
[0])
70 f
.write("""\\end{twocollist}\itemsep=0pt
72 %% --- --- --- generated code ends here --- --- ---
89 if ican
== '"-"': ican
= '""'
91 if ilang
== '-': ilang
= '0'
93 if isublang
== '-': isublang
= '0'
95 ilayout
= "wxLayout_LeftToRight"
97 ilayout
= "wxLayout_RightToLeft"
99 print "ERROR: Invalid value for the layout direction";
100 lngtable
+= ' LNG(%-38s %-7s, %-15s, %-34s, %s, %s)\n' % \
101 ((i
[0]+','), ican
, ilang
, isublang
, ilayout
, i
[5])
102 if ilang
not in all_langs
: all_langs
.append(ilang
)
103 if isublang
not in all_sublangs
: all_sublangs
.append(isublang
)
107 ifdefs
+= '#ifndef %s\n#define %s (0)\n#endif\n' % (s
, s
)
108 for s
in all_sublangs
:
109 if s
!= '0' and s
!= 'SUBLANG_DEFAULT':
110 ifdefs
+= '#ifndef %s\n#define %s SUBLANG_DEFAULT\n#endif\n' % (s
, s
)
112 f
= open('_wxlang.cpp', 'wt')
114 // --- --- --- generated code begins here --- --- ---
116 // This table is generated by misc/languages/genlang.py
117 // When making changes, please put them into misc/languages/langtabl.txt
119 #if !defined(__WIN32__) || defined(__WXMICROWIN__)
121 #define SETWINLANG(info,lang,sublang)
125 #define SETWINLANG(info,lang,sublang) \\
126 info.WinLang = lang, info.WinSublang = sublang;
132 #define LNG(wxlang, canonical, winlang, winsublang, layout, desc) \\
133 info.Language = wxlang; \\
134 info.CanonicalName = wxT(canonical); \\
135 info.LayoutDirection = layout; \\
136 info.Description = wxT(desc); \\
137 SETWINLANG(info, winlang, winsublang) \\
140 void wxLocale::InitLanguagesDB()
143 wxStringTokenizer tkn;
149 // --- --- --- generated code ends here --- --- ---
151 """ % (ifdefs
, lngtable
))