[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [55403] trunk/blender/release/scripts/ modules/bl_i18n_utils: Some renaming/cleanup in i18n tools.
Bastien Montagne
montagne29 at wanadoo.fr
Tue Mar 19 09:33:24 CET 2013
Revision: 55403
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=55403
Author: mont29
Date: 2013-03-19 08:33:24 +0000 (Tue, 19 Mar 2013)
Log Message:
-----------
Some renaming/cleanup in i18n tools.
Modified Paths:
--------------
trunk/blender/release/scripts/modules/bl_i18n_utils/bl_extract_messages.py
trunk/blender/release/scripts/modules/bl_i18n_utils/settings.py
trunk/blender/release/scripts/modules/bl_i18n_utils/utils.py
Added Paths:
-----------
trunk/blender/release/scripts/modules/bl_i18n_utils/settings_user.py
trunk/blender/release/scripts/modules/bl_i18n_utils/utils_languages_menu.py
trunk/blender/release/scripts/modules/bl_i18n_utils/utils_rtl.py
trunk/blender/release/scripts/modules/bl_i18n_utils/utils_spell_check.py
Removed Paths:
-------------
trunk/blender/release/scripts/modules/bl_i18n_utils/languages_menu_utils.py
trunk/blender/release/scripts/modules/bl_i18n_utils/rtl_utils.py
trunk/blender/release/scripts/modules/bl_i18n_utils/spell_check_utils.py
trunk/blender/release/scripts/modules/bl_i18n_utils/user_settings.py
Modified: trunk/blender/release/scripts/modules/bl_i18n_utils/bl_extract_messages.py
===================================================================
--- trunk/blender/release/scripts/modules/bl_i18n_utils/bl_extract_messages.py 2013-03-19 07:46:32 UTC (rev 55402)
+++ trunk/blender/release/scripts/modules/bl_i18n_utils/bl_extract_messages.py 2013-03-19 08:33:24 UTC (rev 55403)
@@ -30,7 +30,7 @@
import sys
# XXX Relative import does not work here when used from Blender...
-from bl_i18n_utils import settings as i18n_settings, utils
+from bl_i18n_utils import settings as settings_i18n, utils
import bpy
@@ -43,10 +43,10 @@
def init_spell_check(settings, lang="en_US"):
try:
- from bl_i18n_utils import spell_check_utils
- return spell_check_utils.SpellChecker(settings, lang)
+ from bl_i18n_utils import utils_spell_check
+ return utils_spell_check.SpellChecker(settings, lang)
except Exception as e:
- print("Failed to import spell_check_utils ({})".format(str(e)))
+ print("Failed to import utils_spell_check ({})".format(str(e)))
return None
@@ -901,7 +901,7 @@
help="Override (some) default settings. Either a JSon file name, or a JSon string.")
args = parser.parse_args()
- settings = i18n_settings.I18nSettings()
+ settings = settings_i18n.I18nSettings()
settings.from_json(args.settings)
if args.output:
Deleted: trunk/blender/release/scripts/modules/bl_i18n_utils/languages_menu_utils.py
===================================================================
--- trunk/blender/release/scripts/modules/bl_i18n_utils/languages_menu_utils.py 2013-03-19 07:46:32 UTC (rev 55402)
+++ trunk/blender/release/scripts/modules/bl_i18n_utils/languages_menu_utils.py 2013-03-19 08:33:24 UTC (rev 55403)
@@ -1,96 +0,0 @@
-# ***** BEGIN GPL LICENSE BLOCK *****
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-# ***** END GPL LICENSE BLOCK *****
-
-# <pep8 compliant>
-
-# Update "languages" text file used by Blender at runtime to build translations menu.
-
-
-import os
-
-
-OK = 0
-MISSING = 1
-TOOLOW = 2
-FORBIDDEN = 3
-FLAG_MESSAGES = {
- OK: "",
- MISSING: "No translation yet!",
- TOOLOW: "Not enough advanced to be included...",
- FORBIDDEN: "Explicitly forbidden!",
-}
-
-def gen_menu_file(stats, settings):
- # Generate languages file used by Blender's i18n system.
- # First, match all entries in LANGUAGES to a lang in stats, if possible!
- tmp = []
- for uid_num, label, uid, in settings.LANGUAGES:
- if uid in stats:
- if uid in settings.IMPORT_LANGUAGES_SKIP:
- tmp.append((stats[uid], uid_num, label, uid, FORBIDDEN))
- else:
- tmp.append((stats[uid], uid_num, label, uid, OK))
- else:
- tmp.append((0.0, uid_num, label, uid, MISSING))
- stats = tmp
- limits = sorted(settings.LANGUAGES_CATEGORIES, key=lambda it: it[0], reverse=True)
- idx = 0
- stats = sorted(stats, key=lambda it: it[0], reverse=True)
- langs_cats = [[] for i in range(len(limits))]
- highest_uid = 0
- for lvl, uid_num, label, uid, flag in stats:
- if lvl < limits[idx][0]:
- # Sub-sort languages by iso-codes.
- langs_cats[idx].sort(key=lambda it: it[2])
- idx += 1
- if lvl < settings.IMPORT_MIN_LEVEL and flag == OK:
- flag = TOOLOW
- langs_cats[idx].append((uid_num, label, uid, flag))
- if abs(uid_num) > highest_uid:
- highest_uid = abs(uid_num)
- # Sub-sort last group of languages by iso-codes!
- langs_cats[idx].sort(key=lambda it: it[2])
- data_lines = [
- "# File used by Blender to know which languages (translations) are available, ",
- "# and to generate translation menu.",
- "#",
- "# File format:",
- "# ID:MENULABEL:ISOCODE",
- "# ID must be unique, except for 0 value (marks categories for menu).",
- "# Line starting with a # are comments!",
- "#",
- "# Automatically generated by bl_i18n_utils/update_languages_menu.py script.",
- "# Highest ID currently in use: {}".format(highest_uid),
- ]
- for cat, langs_cat in zip(limits, langs_cats):
- data_lines.append("#")
- # Write "category menu label"...
- if langs_cat:
- data_lines.append("0:{}:".format(cat[1]))
- else:
- # Do not write the category if it has no language!
- data_lines.append("# Void category! #0:{}:".format(cat[1]))
- # ...and all matching language entries!
- for uid_num, label, uid, flag in langs_cat:
- if flag == OK:
- data_lines.append("{}:{}:{}".format(uid_num, label, uid))
- else:
- # Non-existing, commented entry!
- data_lines.append("# {} #{}:{}:{}".format(FLAG_MESSAGES[flag], uid_num, label, uid))
- with open(os.path.join(settings.TRUNK_MO_DIR, settings.LANGUAGES_FILE), 'w') as f:
- f.write("\n".join(data_lines))
Deleted: trunk/blender/release/scripts/modules/bl_i18n_utils/rtl_utils.py
===================================================================
--- trunk/blender/release/scripts/modules/bl_i18n_utils/rtl_utils.py 2013-03-19 07:46:32 UTC (rev 55402)
+++ trunk/blender/release/scripts/modules/bl_i18n_utils/rtl_utils.py 2013-03-19 08:33:24 UTC (rev 55403)
@@ -1,195 +0,0 @@
-#!/usr/bin/python3
-
-# ***** BEGIN GPL LICENSE BLOCK *****
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-# ***** END GPL LICENSE BLOCK *****
-
-# <pep8 compliant>
-
-# Preprocess right-to-left languages.
-# You can use it either standalone, or through import_po_from_branches or
-# update_trunk.
-#
-# Notes: This has been tested on Linux, not 100% it will work nicely on
-# Windows or OsX.
-# This uses ctypes, as there is no py3 binding for fribidi currently.
-# This implies you only need the compiled C library to run it.
-# Finally, note that it handles some formating/escape codes (like
-# \", %s, %x12, %.4f, etc.), protecting them from ugly (evil) fribidi,
-# which seems completely unaware of such things (as unicode is...).
-
-import sys
-import ctypes
-import re
-
-
-#define FRIBIDI_MASK_NEUTRAL 0x00000040L /* Is neutral */
-FRIBIDI_PAR_ON = 0x00000040
-
-
-#define FRIBIDI_FLAG_SHAPE_MIRRORING 0x00000001
-#define FRIBIDI_FLAG_REORDER_NSM 0x00000002
-
-#define FRIBIDI_FLAG_SHAPE_ARAB_PRES 0x00000100
-#define FRIBIDI_FLAG_SHAPE_ARAB_LIGA 0x00000200
-#define FRIBIDI_FLAG_SHAPE_ARAB_CONSOLE 0x00000400
-
-#define FRIBIDI_FLAG_REMOVE_BIDI 0x00010000
-#define FRIBIDI_FLAG_REMOVE_JOINING 0x00020000
-#define FRIBIDI_FLAG_REMOVE_SPECIALS 0x00040000
-
-#define FRIBIDI_FLAGS_DEFAULT ( \
-# FRIBIDI_FLAG_SHAPE_MIRRORING | \
-# FRIBIDI_FLAG_REORDER_NSM | \
-# FRIBIDI_FLAG_REMOVE_SPECIALS )
-
-#define FRIBIDI_FLAGS_ARABIC ( \
-# FRIBIDI_FLAG_SHAPE_ARAB_PRES | \
-# FRIBIDI_FLAG_SHAPE_ARAB_LIGA )
-
-FRIBIDI_FLAG_SHAPE_MIRRORING = 0x00000001
-FRIBIDI_FLAG_REORDER_NSM = 0x00000002
-FRIBIDI_FLAG_REMOVE_SPECIALS = 0x00040000
-
-FRIBIDI_FLAG_SHAPE_ARAB_PRES = 0x00000100
-FRIBIDI_FLAG_SHAPE_ARAB_LIGA = 0x00000200
-
-FRIBIDI_FLAGS_DEFAULT = FRIBIDI_FLAG_SHAPE_MIRRORING | FRIBIDI_FLAG_REORDER_NSM | FRIBIDI_FLAG_REMOVE_SPECIALS
-
-FRIBIDI_FLAGS_ARABIC = FRIBIDI_FLAG_SHAPE_ARAB_PRES | FRIBIDI_FLAG_SHAPE_ARAB_LIGA
-
-
-MENU_DETECT_REGEX = re.compile("%x\\d+\\|")
-
-
-##### Kernel processing funcs. #####
-def protect_format_seq(msg):
- """
- Find some specific escaping/formating sequences (like \", %s, etc.,
- and protect them from any modification!
- """
-# LRM = "\u200E"
-# RLM = "\u200F"
- LRE = "\u202A"
- RLE = "\u202B"
- PDF = "\u202C"
- LRO = "\u202D"
- RLO = "\u202E"
- uctrl = {LRE, RLE, PDF, LRO, RLO}
- # Most likely incomplete, but seems to cover current needs.
- format_codes = set("tslfd")
- digits = set(".0123456789")
-
- if not msg:
- return msg
- elif MENU_DETECT_REGEX.search(msg):
- # An ugly "menu" message, just force it whole LRE if not yet done.
- if msg[0] not in {LRE, LRO}:
- msg = LRE + msg
-
- idx = 0
- ret = []
- ln = len(msg)
- while idx < ln:
- dlt = 1
-# # If we find a control char, skip any additional protection!
-# if msg[idx] in uctrl:
-# ret.append(msg[idx:])
-# break
- # \" or \'
- if idx < (ln - 1) and msg[idx] == '\\' and msg[idx + 1] in "\"\'":
- dlt = 2
- # %x12|
- elif idx < (ln - 2) and msg[idx] == '%' and msg[idx + 1] in "x" and msg[idx + 2] in digits:
- dlt = 2
- while (idx + dlt) < ln and msg[idx + dlt] in digits:
- dlt += 1
- if (idx + dlt) < ln and msg[idx + dlt] is '|':
- dlt += 1
- # %.4f
- elif idx < (ln - 3) and msg[idx] == '%' and msg[idx + 1] in digits:
- dlt = 2
- while (idx + dlt) < ln and msg[idx + dlt] in digits:
- dlt += 1
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list