blender/po/update_pot.py
Sergey Sharybin 0eda51f2ea Fixing issues with i18n stuff:
- Make gettext stuff draw-time. so switching between languages
  can happens without restart now.
- Added option to translate visible interface (menus, buttons, labels)
  and tooltips. Now it's possible to have english UI and localized tooltips.
- Clean-up sources, do not use gettext stuff for things which can be
  collected with RNA.
- Fix issues with windows 64bit and ru_RU locale on my desktop
  (it was codepage issue).
- Added operator "Get Messages" which generates new text block with
  with all strings collected from RNA.
- Changed script for updating blender.pot so now it appends
  messages collected from rna to automatically gathered messages.
  To update .pot you have to re-generate messages.txt using "Get Messages"
  operator and then run update_pot script.
- Clean up old translation stuff which wasn't used and most probably
  wouldn't be used.
- Return back "International Fonts" option, so if it's disabled, no
  gettext lookups happens on draw.
- Merged read_homefile function back. No need in splitting it.

TODO:
- Custom fonts and font size.
  Current font isn't nice at least for russian locale, it's
  difficult to read it.
- Put references to messages.txt so gettext can merge translation when
  name/description of some property changes.
2011-09-15 13:20:18 +00:00

62 lines
1.6 KiB
Python
Executable File

#!/usr/bin/python
# update the pot file according the POTFILES.in
import os
GETTEXT_XGETTEXT_EXECUTABLE="xgettext"
SOURCE_DIR=".."
DOMAIN="blender"
cmd = "%s --files-from=%s/po/POTFILES.in --keyword=_ --keyword=N_ --directory=%s --output=%s/po/%s.pot --from-code=utf-8" % (
GETTEXT_XGETTEXT_EXECUTABLE, SOURCE_DIR, SOURCE_DIR, SOURCE_DIR, DOMAIN)
os.system( cmd )
def stripeol(s):
if line.endswith("\n"):
s = s[:-1]
if line.endswith("\r"):
s = s[:-1]
return s
pot_messages = {}
reading_message = False
message = ""
with open("blender.pot", 'r') as handle:
while True:
line = handle.readline()
if not line:
break
line = stripeol(line)
if line.startswith("msgid"):
reading_message = True
message = line[7:-1]
elif line.startswith("msgstr"):
reading_message = False
pot_messages[message] = True
elif reading_message:
message += line[1:-1]
# add messages collected automatically from RNA
with open("blender.pot", "a") as pot_handle:
with open("messages.txt", 'r') as handle:
while True:
line = handle.readline()
if not line:
break
line = stripeol(line)
line = line.replace("\\", "\\\\")
line = line.replace("\"", "\\\"")
if not pot_messages.get(line):
pot_handle.write("\n#: Automatically collected from RNA\n")
pot_handle.write("msgid \"%s\"\n" % (line))
pot_handle.write("msgstr \"\"\n")