X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d3f3e35f54cd316be25043e80146fb6102b9c59d..93cd80d63c45b754387edac7bdb89e7342c70e28:/misc/languages/genlang.py?ds=sidebyside diff --git a/misc/languages/genlang.py b/misc/languages/genlang.py index 2a09dae04b..e6b15875f8 100755 --- a/misc/languages/genlang.py +++ b/misc/languages/genlang.py @@ -20,6 +20,9 @@ def ReadTable(): def GenEnum(table): f = open('_wxlang.h', 'wt') f.write(""" + +// --- --- --- generated code begins here --- --- --- + // This enum is generated by misc/languages/genlang.py // When making changes, please put them into misc/languages/langtabl.txt enum wxLanguage @@ -36,6 +39,34 @@ enum wxLanguage // for custom, user-defined languages: wxLANGUAGE_USER_DEFINED }; + +// --- --- --- generated code ends here --- --- --- + +""") + f.close() + + +def GenDocs(table): + f = open('_wxlang.tex', 'wt') + f.write(""" + +%% --- --- --- generated code begins here --- --- --- + +%% This enum is generated by misc/languages/genlang.py +%% When making changes, please put them into misc/languages/langtabl.txt +\\begin{itemize}\\itemsep=0pt +\\item wxLANGUAGE_DEFAULT -- user's default language as obtained from the operating system +\\item wxLANGUAGE_UNKNOWN -- returned by \\helpref{GetSystemLanguage}{wxlocalegetsystemlanguage} +if it fails to detect the default language +\\item wxLANGUAGE_USER_DEFINED -- user defined languages' integer identifiers should start from +this +"""); + for i in table: + f.write('\\item %s\n' % (i[0].replace('_','\\_'))) + f.write("""\\end{itemize} + +%% --- --- --- generated code ends here --- --- --- + """) f.close() @@ -43,17 +74,50 @@ enum wxLanguage def GenTable(table): + all_langs = [] + all_sublangs = [] + + lngtable = '' + ifdefs = '' + + for i in table: + ican = '"%s"' % i[1] + if ican == '"-"': ican = '""' + ilang = i[2] + if ilang == '-': ilang = '0' + isublang = i[3] + if isublang == '-': isublang = '0' + lngtable += ' LNG(%-38s %-7s, %-15s, %-34s, %s)\n' % \ + ((i[0]+','), ican, ilang, isublang, i[4]) + if ilang not in all_langs: all_langs.append(ilang) + if isublang not in all_sublangs: all_sublangs.append(isublang) + + for s in all_langs: + if s != '0': + ifdefs += '#ifndef %s\n#define %s (0)\n#endif\n' % (s, s) + for s in all_sublangs: + if s != '0' and s != 'SUBLANG_DEFAULT': + ifdefs += '#ifndef %s\n#define %s SUBLANG_DEFAULT\n#endif\n' % (s, s) + f = open('_wxlang.cpp', 'wt') f.write(""" +// --- --- --- generated code begins here --- --- --- + // This table is generated by misc/languages/genlang.py // When making changes, please put them into misc/languages/langtabl.txt -#ifdef __WXMSW__ +#ifndef __WIN32__ + +#define SETWINLANG(info,lang,sublang) + +#else + #define SETWINLANG(info,lang,sublang) \\ info.WinLang = lang, info.WinSublang = sublang; -#else -#define SETWINLANG(info,lang,sublang) -#endif + +%s + +#endif // __WIN32__ #define LNG(wxlang, canonical, winlang, winsublang, desc) \\ info.Language = wxlang; \\ @@ -66,21 +130,14 @@ void wxLocale::InitLanguagesDB() { wxLanguageInfo info; wxStringTokenizer tkn; - -"""); - for i in table: - ican = '"%s"' % i[1] - if ican == '"-"': ican = '""' - ilang = i[2] - if ilang == '-': ilang = '0' - isublang = i[3] - if isublang == '-': isublang = '0' - f.write(' LNG(%-38s %-7s, %-15s, %-34s, %s)\n' % \ - ((i[0]+','), ican, ilang, isublang, i[4])) - f.write("""}; + %s +}; #undef LNG -""") + +// --- --- --- generated code ends here --- --- --- + +""" % (ifdefs, lngtable)) f.close() @@ -90,3 +147,4 @@ void wxLocale::InitLanguagesDB() table = ReadTable() GenEnum(table) GenTable(table) +GenDocs(table)