]>
git.saurik.com Git - wxWidgets.git/blob - misc/languages/genlang.py
4 # This script must be ran from misc/languages subdirectory.
6 # It generates wxLanguage enum (to be cut&pasted to include/wx/intl.h)
7 # and conversion tables (ditto to src/common/intl.cpp)
14 f
= open('langtabl.txt')
15 for i
in f
.readlines():
17 table
.append((ispl
[0], ispl
[1], ispl
[2], ispl
[3], ispl
[4], string
.join(ispl
[5:])))
23 f
= open('_wxlang.h', 'wt')
26 // --- --- --- generated code begins here --- --- ---
29 The languages supported by wxLocale.
31 This enum is generated by misc/languages/genlang.py
32 When making changes, please put them into misc/languages/langtabl.txt
36 /// User's default/preffered language as got from OS.
39 /// Unknown language, returned if wxLocale::GetSystemLanguage fails.
45 if i
[0] not in knownLangs
:
46 f
.write(' %s,\n' % i
[0])
47 knownLangs
.append(i
[0])
49 /// For custom, user-defined languages.
50 wxLANGUAGE_USER_DEFINED
53 // --- --- --- generated code ends here --- --- ---
68 if ican
== '"-"': ican
= '""'
70 if ilang
== '-': ilang
= '0'
72 if isublang
== '-': isublang
= '0'
74 ilayout
= "wxLayout_LeftToRight"
76 ilayout
= "wxLayout_RightToLeft"
78 print "ERROR: Invalid value for the layout direction";
79 lngtable
+= ' LNG(%-38s %-7s, %-15s, %-34s, %s, %s)\n' % \
80 ((i
[0]+','), ican
, ilang
, isublang
, ilayout
, i
[5])
81 if ilang
not in all_langs
: all_langs
.append(ilang
)
82 if isublang
not in all_sublangs
: all_sublangs
.append(isublang
)
86 ifdefs
+= '#ifndef %s\n#define %s (0)\n#endif\n' % (s
, s
)
87 for s
in all_sublangs
:
88 if s
!= '0' and s
!= 'SUBLANG_DEFAULT':
89 ifdefs
+= '#ifndef %s\n#define %s SUBLANG_DEFAULT\n#endif\n' % (s
, s
)
91 f
= open('_wxlang.cpp', 'wt')
93 // --- --- --- generated code begins here --- --- ---
95 // This table is generated by misc/languages/genlang.py
96 // When making changes, please put them into misc/languages/langtabl.txt
98 #if !defined(__WIN32__) || defined(__WXMICROWIN__)
100 #define SETWINLANG(info,lang,sublang)
104 #define SETWINLANG(info,lang,sublang) \\
105 info.WinLang = lang, info.WinSublang = sublang;
111 #define LNG(wxlang, canonical, winlang, winsublang, layout, desc) \\
112 info.Language = wxlang; \\
113 info.CanonicalName = wxT(canonical); \\
114 info.LayoutDirection = layout; \\
115 info.Description = wxT(desc); \\
116 SETWINLANG(info, winlang, winsublang) \\
119 void wxLocale::InitLanguagesDB()
122 wxStringTokenizer tkn;
128 // --- --- --- generated code ends here --- --- ---
130 """ % (ifdefs
, lngtable
))
138 GenEnum(table
) # the enum is used also (thanks to doxygen) in the docs