diff options
author | Xiao Xiangquan <xiaoxiangquan@gmail.com> | 2011-06-10 08:36:51 +0400 |
---|---|---|
committer | Xiao Xiangquan <xiaoxiangquan@gmail.com> | 2011-06-10 08:36:51 +0400 |
commit | 34a22b3b78b6c577fdb048751f58cce89f68a2d9 (patch) | |
tree | 7568693b918cdaf882b4830ace931f00403bd6c3 | |
parent | aac6369e681d8d713264b2234ac30a5e90b07be0 (diff) |
Add i18n support for C code, and most menu items can be translated, now
-rwxr-xr-x | po/POTFILES.in | 3 | ||||
-rwxr-xr-x | po/update_all.py | 7 | ||||
-rwxr-xr-x | po/update_mo.py | 40 | ||||
-rwxr-xr-x | po/update_po.py (renamed from po/update-po.py) | 5 | ||||
-rwxr-xr-x | po/update_pot.py (renamed from po/update-pot.py) | 0 | ||||
-rw-r--r-- | source/blender/blenfont/BLF_api.h | 2 | ||||
-rw-r--r-- | source/blender/editors/space_info/space_info.c | 6 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_init_exit.c | 21 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_operators.c | 63 |
9 files changed, 99 insertions, 48 deletions
diff --git a/po/POTFILES.in b/po/POTFILES.in index fb0f96cc6ae..ac949ade10a 100755 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -1 +1,4 @@ release/scripts/startup/bl_ui/space_info.py + +source/blender/editors/space_info/space_info.c +source/blender/windowmanager/intern/wm_operators.c diff --git a/po/update_all.py b/po/update_all.py new file mode 100755 index 00000000000..c961cbd2503 --- /dev/null +++ b/po/update_all.py @@ -0,0 +1,7 @@ +#!/usr/bin/python + +#update all + +import update_pot +import update_po +import update_mo diff --git a/po/update_mo.py b/po/update_mo.py new file mode 100755 index 00000000000..840d2ff0fea --- /dev/null +++ b/po/update_mo.py @@ -0,0 +1,40 @@ +#!/usr/bin/python + +#update all mo files in the LANGS + +import os + +LOCALE_DIR="../release/bin/.blender/locale" +DOMAIN = "blender" +LANGS = ( + "ar", + "bg", + "ca", + "cs", + "de", + "el", + "es", + "fi", + "fr", + "hr", + "it", + "ja", + "ko", + "nl", + "pl", + "pt_BR", + "ro", + "ru", + "sr@Latn", + "sr", + "sv", + "uk", + "zh_CN" +) + +#-o %s.new.po +for lang in LANGS: + # show stats + cmd = "msgfmt --statistics %s.po -o %s/%s/LC_MESSAGES/%s.mo" % ( lang, LOCALE_DIR, lang, DOMAIN ) + print cmd + os.system( cmd ) diff --git a/po/update-po.py b/po/update_po.py index c824b537a95..640b3a5f2d2 100755 --- a/po/update-po.py +++ b/po/update_po.py @@ -36,7 +36,4 @@ for lang in LANGS: cmd = "msgmerge --update --lang=%s %s.po %s.pot" % (lang, lang, DOMAIN) print(cmd) os.system( cmd ) - - # show stats - cmd = "msgfmt --statistics %s.po" % lang - os.system( cmd ) + diff --git a/po/update-pot.py b/po/update_pot.py index 4ba918d8de5..4ba918d8de5 100755 --- a/po/update-pot.py +++ b/po/update_pot.py diff --git a/source/blender/blenfont/BLF_api.h b/source/blender/blenfont/BLF_api.h index ed86cf7fa3d..e305345d6bc 100644 --- a/source/blender/blenfont/BLF_api.h +++ b/source/blender/blenfont/BLF_api.h @@ -223,6 +223,6 @@ extern int blf_mono_font_render; // dont mess drawing with render threads. // XXX, me, too extern int blf_unifont; extern int blf_unifont_render; // dont mess drawing with render threads. -#define _(msgid) (msgid) +#define _(msgid) BLF_gettext(msgid) #endif /* BLF_API_H */ diff --git a/source/blender/editors/space_info/space_info.c b/source/blender/editors/space_info/space_info.c index bd2e8077eab..beb9f7dc589 100644 --- a/source/blender/editors/space_info/space_info.c +++ b/source/blender/editors/space_info/space_info.c @@ -41,6 +41,8 @@ #include "BLI_rand.h" #include "BLI_utildefines.h" +#include "BLF_api.h" + #include "BKE_context.h" #include "BKE_global.h" #include "BKE_screen.h" @@ -278,7 +280,7 @@ static void recent_files_menu_draw(const bContext *UNUSED(C), Menu *menu) uiItemStringO(layout, BLI_path_basename(recent->filepath), ICON_FILE_BLEND, "WM_OT_open_mainfile", "filepath", recent->filepath); } } else { - uiItemL(layout, "No Recent Files", ICON_NONE); + uiItemL(layout, _("No Recent Files"), ICON_NONE); } } @@ -288,7 +290,7 @@ static void recent_files_menu_register(void) mt= MEM_callocN(sizeof(MenuType), "spacetype info menu recent files"); strcpy(mt->idname, "INFO_MT_file_open_recent"); - strcpy(mt->label, "Open Recent..."); + strcpy(mt->label, _("Open Recent...")); mt->draw= recent_files_menu_draw; WM_menutype_add(mt); } diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index a27be49af43..4acf5157ff1 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -126,16 +126,6 @@ void WM_init(bContext *C, int argc, const char **argv) wm_init_cursor_data(); } GHOST_CreateSystemPaths(); - wm_operatortype_init(); - - set_free_windowmanager_cb(wm_close_and_free); /* library.c */ - set_blender_test_break_cb(wm_window_testbreak); /* blender.c */ - DAG_editors_update_cb(ED_render_id_flush_update); /* depsgraph.c */ - - ED_spacetypes_init(); /* editors/space_api/spacetype.c */ - - ED_file_init(); /* for fsmenu */ - ED_init_node_butfuncs(); BLF_init(11, U.dpi); /* Please update source/gamengine/GamePlayer/GPG_ghost.cpp if you change this */ BLF_lang_init(); @@ -143,6 +133,17 @@ void WM_init(bContext *C, int argc, const char **argv) BLF_lang_encoding(""); BLF_lang_set(""); + wm_operatortype_init(); + + set_free_windowmanager_cb(wm_close_and_free); /* library.c */ + set_blender_test_break_cb(wm_window_testbreak); /* blender.c */ + DAG_editors_update_cb(ED_render_id_flush_update); /* depsgraph.c */ + + ED_spacetypes_init(); /* editors/space_api/spacetype.c */ + + ED_file_init(); /* for fsmenu */ + ED_init_node_butfuncs(); + /* get the default database, plus a wm */ WM_read_homefile(C, NULL, G.factory_startup); diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 34702558bc8..bb9804273ee 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -77,6 +77,7 @@ #include "BIF_gl.h" #include "BIF_glutil.h" /* for paint cursor */ +#include "BLF_api.h" #include "IMB_imbuf_types.h" @@ -346,7 +347,7 @@ wmOperatorType *WM_operatortype_append_macro(const char *idname, const char *nam ot->poll= NULL; if(!ot->description) - ot->description= "(undocumented operator)"; + ot->description= _("(undocumented operator)"); RNA_def_struct_ui_text(ot->srna, ot->name, ot->description); // XXX All ops should have a description but for now allow them not to. RNA_def_struct_identifier(ot->srna, ot->idname); @@ -371,7 +372,7 @@ void WM_operatortype_append_macro_ptr(void (*opfunc)(wmOperatorType*, void*), vo ot->poll= NULL; if(!ot->description) - ot->description= "(undocumented operator)"; + ot->description= _("(undocumented operator)"); opfunc(ot, userdata); @@ -766,7 +767,7 @@ int WM_operator_confirm_message(bContext *C, wmOperator *op, const char *message else properties= NULL; - pup= uiPupMenuBegin(C, "OK?", ICON_QUESTION); + pup= uiPupMenuBegin(C, _("OK?"), ICON_QUESTION); layout= uiPupMenuLayout(pup); uiItemFullO(layout, op->type->idname, message, ICON_NONE, properties, WM_OP_EXEC_REGION_WIN, 0); uiPupMenuEnd(C, pup); @@ -981,7 +982,7 @@ static uiBlock *wm_block_create_dialog(bContext *C, ARegion *ar, void *userData) col= uiLayoutColumn(layout, FALSE); col_block= uiLayoutGetBlock(col); /* Create OK button, the callback of which will execute op */ - btn= uiDefBut(col_block, BUT, 0, "OK", 0, -30, 0, 20, NULL, 0, 0, 0, 0, ""); + btn= uiDefBut(col_block, BUT, 0, _("OK"), 0, -30, 0, 20, NULL, 0, 0, 0, 0, ""); uiButSetFunc(btn, dialog_exec_cb, op, col_block); } @@ -1094,7 +1095,7 @@ static void WM_OT_debug_menu(wmOperatorType *ot) { ot->name= "Debug Menu"; ot->idname= "WM_OT_debug_menu"; - ot->description= "Open a popup to set the debug level"; + ot->description= _("Open a popup to set the debug level"); ot->invoke= wm_debug_menu_invoke; ot->exec= wm_debug_menu_exec; @@ -1208,19 +1209,19 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar split = uiLayoutSplit(layout, 0, 0); col = uiLayoutColumn(split, 0); - uiItemL(col, "Links", ICON_NONE); - uiItemStringO(col, "Donations", ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/blenderorg/blender-foundation/donation-payment/"); - uiItemStringO(col, "Release Log", ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/development/release-logs/blender-257/"); - uiItemStringO(col, "Manual", ICON_URL, "WM_OT_url_open", "url", "http://wiki.blender.org/index.php/Doc:2.5/Manual"); - uiItemStringO(col, "Blender Website", ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/"); - uiItemStringO(col, "User Community", ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/community/user-community/"); // + uiItemL(col, _("Links"), ICON_NONE); + uiItemStringO(col, _("Donations"), ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/blenderorg/blender-foundation/donation-payment/"); + uiItemStringO(col, _("Release Log"), ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/development/release-logs/blender-257/"); + uiItemStringO(col, _("Manual"), ICON_URL, "WM_OT_url_open", "url", "http://wiki.blender.org/index.php/Doc:2.5/Manual"); + uiItemStringO(col, _("Blender Website"), ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/"); + uiItemStringO(col, _("User Community"), ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/community/user-community/"); // if(strcmp(STRINGIFY(BLENDER_VERSION_CYCLE), "release")==0) { BLI_snprintf(url, sizeof(url), "http://www.blender.org/documentation/blender_python_api_%d_%d" STRINGIFY(BLENDER_VERSION_CHAR) "_release", BLENDER_VERSION/100, BLENDER_VERSION%100); } else { BLI_snprintf(url, sizeof(url), "http://www.blender.org/documentation/blender_python_api_%d_%d_%d", BLENDER_VERSION/100, BLENDER_VERSION%100, BLENDER_SUBVERSION); } - uiItemStringO(col, "Python API Reference", ICON_URL, "WM_OT_url_open", "url", url); + uiItemStringO(col, _("Python API Reference"), ICON_URL, "WM_OT_url_open", "url", url); uiItemL(col, "", ICON_NONE); col = uiLayoutColumn(split, 0); @@ -1230,7 +1231,7 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar uiItemS(col); } - uiItemL(col, "Recent", ICON_NONE); + uiItemL(col, _("Recent"), ICON_NONE); for(recent = G.recent_files.first, i=0; (i<5) && (recent); recent = recent->next, i++) { uiItemStringO(col, BLI_path_basename(recent->filepath), ICON_FILE_BLEND, "WM_OT_open_mainfile", "filepath", recent->filepath); } @@ -1408,9 +1409,9 @@ static int wm_operator_winactive_normal(bContext *C) static void WM_OT_window_duplicate(wmOperatorType *ot) { - ot->name= "Duplicate Window"; + ot->name= _("Duplicate Window"); ot->idname= "WM_OT_window_duplicate"; - ot->description="Duplicate the current Blender window"; + ot->description=_("Duplicate the current Blender window"); ot->exec= wm_window_duplicate_exec; ot->poll= wm_operator_winactive_normal; @@ -1418,9 +1419,9 @@ static void WM_OT_window_duplicate(wmOperatorType *ot) static void WM_OT_save_homefile(wmOperatorType *ot) { - ot->name= "Save User Settings"; + ot->name= _("Save User Settings"); ot->idname= "WM_OT_save_homefile"; - ot->description="Make the current file the default .blend file"; + ot->description=_("Make the current file the default .blend file"); ot->invoke= WM_operator_confirm; ot->exec= WM_write_homefile; @@ -1429,9 +1430,9 @@ static void WM_OT_save_homefile(wmOperatorType *ot) static void WM_OT_read_homefile(wmOperatorType *ot) { - ot->name= "Reload Start-Up File"; + ot->name= _("Reload Start-Up File"); ot->idname= "WM_OT_read_homefile"; - ot->description="Open the default file (doesn't save the current file)"; + ot->description=_("Open the default file (doesn't save the current file)"); ot->invoke= WM_operator_confirm; ot->exec= WM_read_homefile_exec; @@ -1440,9 +1441,9 @@ static void WM_OT_read_homefile(wmOperatorType *ot) static void WM_OT_read_factory_settings(wmOperatorType *ot) { - ot->name= "Load Factory Settings"; + ot->name= _("Load Factory Settings"); ot->idname= "WM_OT_read_factory_settings"; - ot->description="Load default file and user preferences"; + ot->description=_("Load default file and user preferences"); ot->invoke= WM_operator_confirm; ot->exec= WM_read_homefile_exec; @@ -1517,7 +1518,7 @@ static void WM_OT_open_mainfile(wmOperatorType *ot) { ot->name= "Open Blender File"; ot->idname= "WM_OT_open_mainfile"; - ot->description="Open a Blender file"; + ot->description=_("Open a Blender file"); ot->invoke= wm_open_mainfile_invoke; ot->exec= wm_open_mainfile_exec; @@ -1685,7 +1686,7 @@ static void WM_OT_link_append(wmOperatorType *ot) { ot->name= "Link/Append from Library"; ot->idname= "WM_OT_link_append"; - ot->description= "Link or Append from a Library .blend file"; + ot->description= _("Link or Append from a Library .blend file"); ot->invoke= wm_link_append_invoke; ot->exec= wm_link_append_exec; @@ -1725,9 +1726,9 @@ static int wm_recover_last_session_exec(bContext *C, wmOperator *op) static void WM_OT_recover_last_session(wmOperatorType *ot) { - ot->name= "Recover Last Session"; + ot->name= _("Recover Last Session"); ot->idname= "WM_OT_recover_last_session"; - ot->description="Open the last closed file (\"quit.blend\")"; + ot->description=_("Open the last closed file (\"quit.blend\")"); ot->exec= wm_recover_last_session_exec; ot->poll= WM_operator_winactive; @@ -1770,7 +1771,7 @@ static void WM_OT_recover_auto_save(wmOperatorType *ot) { ot->name= "Recover Auto Save"; ot->idname= "WM_OT_recover_auto_save"; - ot->description="Open an automatically saved file to recover it"; + ot->description=_("Open an automatically saved file to recover it"); ot->exec= wm_recover_auto_save_exec; ot->invoke= wm_recover_auto_save_invoke; @@ -1876,7 +1877,7 @@ static void WM_OT_save_as_mainfile(wmOperatorType *ot) { ot->name= "Save As Blender File"; ot->idname= "WM_OT_save_as_mainfile"; - ot->description="Save the current file in the desired location"; + ot->description=_("Save the current file in the desired location"); ot->invoke= wm_save_as_mainfile_invoke; ot->exec= wm_save_as_mainfile_exec; @@ -1935,7 +1936,7 @@ static void WM_OT_save_mainfile(wmOperatorType *ot) { ot->name= "Save Blender File"; ot->idname= "WM_OT_save_mainfile"; - ot->description="Save the current Blender file"; + ot->description=_("Save the current Blender file"); ot->invoke= wm_save_mainfile_invoke; ot->exec= wm_save_as_mainfile_exec; @@ -2053,7 +2054,7 @@ static void WM_OT_quit_blender(wmOperatorType *ot) { ot->name= "Quit Blender"; ot->idname= "WM_OT_quit_blender"; - ot->description= "Quit Blender"; + ot->description= _("Quit Blender"); ot->invoke= WM_operator_confirm; ot->exec= wm_exit_blender_op; @@ -2074,7 +2075,7 @@ static void WM_OT_console_toggle(wmOperatorType *ot) { ot->name= "Toggle System Console"; ot->idname= "WM_OT_console_toggle"; - ot->description= "Toggle System Console"; + ot->description= _("Toggle System Console"); ot->exec= wm_console_toggle_op; ot->poll= WM_operator_winactive; @@ -3312,7 +3313,7 @@ static void WM_OT_memory_statistics(wmOperatorType *ot) { ot->name= "Memory Statistics"; ot->idname= "WM_OT_memory_statistics"; - ot->description= "Print memory statistics to the console"; + ot->description= _("Print memory statistics to the console"); ot->exec= memory_statistics_exec; } |