]>
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 --- --- ---
27 The languages supported by wxLocale.
29 This enum is generated by misc/languages/genlang.py
30 When making changes, please put them into misc/languages/langtabl.txt
34 /// User's default/preffered language as got from OS.
37 /// Unknown language, returned if wxLocale::GetSystemLanguage fails.
43 if i
[0] not in knownLangs
:
44 f
.write(' %s,\n' % i
[0])
45 knownLangs
.append(i
[0])
47 /// For custom, user-defined languages.
48 wxLANGUAGE_USER_DEFINED
51 // --- --- --- generated code ends here --- --- ---
66 if ican
== '"-"': ican
= '""'
68 if ilang
== '-': ilang
= '0'
70 if isublang
== '-': isublang
= '0'
72 ilayout
= "wxLayout_LeftToRight"
74 ilayout
= "wxLayout_RightToLeft"
76 print "ERROR: Invalid value for the layout direction";
77 lngtable
+= ' LNG(%-38s %-7s, %-15s, %-34s, %s, %s)\n' % \
78 ((i
[0]+','), ican
, ilang
, isublang
, ilayout
, i
[5])
79 if ilang
not in all_langs
: all_langs
.append(ilang
)
80 if isublang
not in all_sublangs
: all_sublangs
.append(isublang
)
84 ifdefs
+= '#ifndef %s\n#define %s (0)\n#endif\n' % (s
, s
)
85 for s
in all_sublangs
:
86 if s
!= '0' and s
!= 'SUBLANG_DEFAULT':
87 ifdefs
+= '#ifndef %s\n#define %s SUBLANG_DEFAULT\n#endif\n' % (s
, s
)
89 f
= open('_wxlang.cpp', 'wt')
91 // --- --- --- generated code begins here --- --- ---
93 // This table is generated by misc/languages/genlang.py
94 // When making changes, please put them into misc/languages/langtabl.txt
96 #if !defined(__WIN32__) || defined(__WXMICROWIN__)
98 #define SETWINLANG(info,lang,sublang)
102 #define SETWINLANG(info,lang,sublang) \\
103 info.WinLang = lang, info.WinSublang = sublang;
109 #define LNG(wxlang, canonical, winlang, winsublang, layout, desc) \\
110 info.Language = wxlang; \\
111 info.CanonicalName = wxT(canonical); \\
112 info.LayoutDirection = layout; \\
113 info.Description = wxT(desc); \\
114 SETWINLANG(info, winlang, winsublang) \\
117 void wxLocale::InitLanguagesDB()
120 wxStringTokenizer tkn;
126 // --- --- --- generated code ends here --- --- ---
128 """ % (ifdefs
, lngtable
))
136 GenEnum(table
) # the enum is used also (thanks to doxygen) in the docs