[Bf-translations-svn] SVN commit: /data/svn/bf-translations [116] trunk/po/tools: Updated tool chain.
bf-translations at blender.org
bf-translations at blender.org
Thu Oct 20 22:58:44 CEST 2011
Revision: 116
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-translations&revision=116
Author: mont29
Date: 2011-10-20 20:58:44 +0000 (Thu, 20 Oct 2011)
Log Message:
-----------
Updated tool chain.
In fact, nearly all tools were modified, sometimes even completely rewriten. Here are the raw main changes, please read README.txt or http://wiki.blender.org/index.php/Dev:2.5/Doc/How_to/Translate_Blender for more details:
* Now, all tools are under /trunk/po/tools dir, and they all have a small help message (-h option).
* Just use update_branches.py to update all po's under /branches, and update_trunk.py to import and update all po's and mo's under /trunk.
*POTFILES.in was updated to match latest commit in blender trunk. Now only 20 files in it (but likely to grow again if/when we tackle BKE_report?\226?\128?\166 calls?\226?\128?\166).
* Languages needing "to_utf" process: your script has been renamed to <language>_to_utf.py, and will be called automatically by relevant tools. Please commit your *raw* (unprocessed) po as <language>.po one.
* Now merge_po.py manage the #fuzzy tag nice (and it can also take more than one po file to merge indst one at once).
* Try check_po.py -s <your_language>, it ouputs some nice stats. ;)
Modified Paths:
--------------
trunk/po/POTFILES.in
trunk/po/README.txt
Added Paths:
-----------
branches/ar/ar_to_utf.py
branches/fa/fa_to_utf.py
trunk/po/tools/
trunk/po/tools/_update_msg.py
trunk/po/tools/check_po.py
trunk/po/tools/clean_po.py
trunk/po/tools/import_po_from_branches.py
trunk/po/tools/merge_po.py
trunk/po/tools/settings_template.py
trunk/po/tools/update_branches.py
trunk/po/tools/update_mo.py
trunk/po/tools/update_msg.py
trunk/po/tools/update_po.py
trunk/po/tools/update_pot.py
trunk/po/tools/update_trunk.py
trunk/po/tools/utils.py
Removed Paths:
-------------
trunk/po/branches_check_po.py
trunk/po/branches_check_progress.py
trunk/po/branches_clean_po.py
trunk/po/branches_update_po.py
trunk/po/check_po.py
trunk/po/clean_po.py
trunk/po/import_po_from_branches.py
trunk/po/merge_po.py
trunk/po/update_mo.py
trunk/po/update_msg.py
trunk/po/update_po.py
trunk/po/update_pot.py
Added: branches/ar/ar_to_utf.py
===================================================================
--- branches/ar/ar_to_utf.py (rev 0)
+++ branches/ar/ar_to_utf.py 2011-10-20 20:58:44 UTC (rev 116)
@@ -0,0 +1,277 @@
+#coding: utf-8
+
+# ***** 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.
+#
+# Authers:
+# -Dalai Felinto
+# -Yousef Harfoush
+# -Bastien Montagne
+#
+# based on The Arabic Writer script by Omar Muhammad
+# thanks for Rabeh Torchi for ideas
+#
+# ***** END GPL LICENSE BLOCK *****
+
+import sys
+import os
+
+
+def stripeol(s):
+ return s.rstrip("\n\r")
+
+
+# Isolated, Beginning, Middle, End
+# http://en.wikipedia.org/wiki/Arabic_alphabet
+# http://en.wikipedia.org/wiki/Arabic_characters_in_Unicode
+alfmd = ["ﺁ","ﺁ","ﺂ","ﺂ"]
+alfhz = ["ﺃ","ﺃ","ﺄ","ﺄ"]
+wowhz = ["ﺅ","ﺅ","ﺆ","ﺆ"]
+alfxr = ["ﺇ","ﺇ","ﺈ","ﺈ"]
+hamzk = ["ﺉ","ﺋ","ﺌ","ﺊ"]
+alfff = ["ﺍ","ﺍ","ﺎ","ﺎ"]
+baaaa = ["ﺏ","ﺑ","ﺒ","ﺐ"]
+tamrb = ["ﺓ","ﺓ","ﺔ","ﺔ"]
+taaaa = ["ﺕ","ﺗ","ﺘ","ﺖ"]
+thaaa = ["ﺙ","ﺛ","ﺜ","ﺚ"]
+geeem = ["ﺝ","ﺟ","ﺠ","ﺞ"]
+haaaa = ["ﺡ","ﺣ","ﺤ","ﺢ"]
+khaaa = ["ﺥ","ﺧ","ﺨ","ﺦ"]
+daaal = ["ﺩ","ﺩ","ﺪ","ﺪ"]
+thaal = ["ﺫ","ﺫ","ﺬ","ﺬ"]
+raaaa = ["ﺭ","ﺭ","ﺮ","ﺮ"]
+zaaai = ["ﺯ","ﺯ","ﺰ","ﺰ"]
+seeen = ["ﺱ","ﺳ","ﺴ","ﺲ"]
+sheen = ["ﺵ","ﺷ","ﺸ","ﺶ"]
+saaad = ["ﺹ","ﺻ","ﺼ","ﺺ"]
+daaad = ["ﺽ","ﺿ","ﻀ","ﺾ"]
+taaah = ["ﻁ","ﻃ","ﻄ","ﻂ"]
+daaah = ["ﻅ","ﻇ","ﻈ","ﻆ"]
+aayen = ["ﻉ","ﻋ","ﻌ","ﻊ"]
+gayen = ["ﻍ","ﻏ","ﻐ","ﻎ"]
+faaaa = ["ﻑ","ﻓ","ﻔ","ﻒ"]
+qaaaf = ["ﻕ","ﻗ","ﻘ","ﻖ"]
+kaaaf = ["ﻙ","ﻛ","ﻜ","ﻚ"]
+laaam = ["ﻝ","ﻟ","ﻠ","ﻞ"]
+meeem = ["ﻡ","ﻣ","ﻤ","ﻢ"]
+nooon = ["ﻥ","ﻧ","ﻨ","ﻦ"]
+hhhhh = ["ﻩ","ﻫ","ﻬ","ﻪ"]
+wowww = ["ﻭ","ﻭ","ﻮ","ﻮ"]
+yaamd = ["ﻯ","ﻯ","ﻰ","ﻰ"]
+yaaaa = ["ﻱ","ﻳ","ﻴ","ﻲ"]
+laamd = ["ﻵ","ﻵ","ﻶ","ﻶ"]
+laahz = ["ﻷ","ﻷ","ﻸ","ﻸ"]
+laaxr = ["ﻹ","ﻹ","ﻺ","ﻺ"]
+laaaa = ["ﻻ","ﻻ","ﻼ","ﻼ"]
+
+# defining numbers
+numbers ="0123456789٠١٢٣٤٥٦٧٨٩"
+#defining arabic unicodec chars
+unicodec ="ﺁﺁﺂﺂﺃﺃﺄﺄﺅﺅﺆﺆﺇﺇﺈﺈﺉﺋﺌﺊﺍﺍﺎﺎﺏﺑﺒﺐﺓﺓﺔﺔﺕﺗﺘﺖﺙﺛﺜﺚﺝﺟﺠﺞﺡﺣﺤﺢﺥﺧﺨﺦﺩﺩﺪﺪﺫﺫﺬﺬﺭﺭﺮﺮﺯﺯﺰﺰﺱﺳﺴﺲﺵﺷﺸﺶﺹﺻﺼﺺﺽﺿﻀﺾﻁﻃﻄﻂﻅﻇﻈﻆﻉﻋﻌﻊﻍﻏﻐﻎﻑﻓﻔﻒﻕﻗﻘﻖﻙﻛﻜﻚﻝﻟﻠﻞﻡﻣﻤﻢﻥﻧﻨﻦﻩﻫﻬﻪﻭﻭﻮﻮﻯﻯﻰﻰﻱﻳﻴﻲﻵﻵﻶﻶﻷﻷﻸﻸﻹﻹﻺﻺﻻﻻﻼﻼ"
+
+# letters that have only Isolated and End forms
+# (and work as word breakers) + laaam and deriveds
+wordbreak ="آأؤإاةدذرزوﻵﻷﻹﻻ"
+
+# defining all arabic letters + harakat
+arabic ="ًٌٍَُِّْْئءؤرلاىةوزظشسيبلاتنمكطضصثقفغعهخحجدذْلآآلأأـلإإ،؟"
+# defining the harakat
+harakat ="ًٌٍَُِّْْ"
+# defining other symbols
+sym ="ًٌٍَُِّـ.،؟ @#$%^&*-+|\/=~(){}ْ,:"
+
+def ProcessInput(input):
+ """main function, the code is not self-explanatory.
+ It requires understanding of arabic alphabet.
+ """
+
+ words = ""
+ x=list(input)
+ ln=len(x)
+
+ #process each letter, submit it to tests and then add it to the output string
+ # we can't do a for loop because we need to change 'g' inside the loop
+ g = 0
+ while g < ln:
+
+ b=a=1 #ignoring/discarding the harakat
+ # see how many chars I need to skip to get the next
+ # non-harakat char in the left (a) or the right (b)
+
+ while g-b >= 0 and x[g-b] in harakat: b+=1
+ while g+a < ln and x[g+a] in harakat: a+=1
+
+ # get the position
+ if x[g] not in wordbreak and g+a < ln and x[g+a] in arabic and x[g+a] != "ء":
+ if g-b >= 0 and x[g-b] not in wordbreak and x[g-b] in arabic and x[g-b] != "ء":
+ pos = 2 # middle
+ else:
+ pos = 1 # beggining
+ else:
+ if g-b >= 0 and x[g-b] not in wordbreak and x[g-b] in arabic and x[g-b] != "ء":
+ pos = 3 # end
+ else:
+ pos = 0 # isolated
+
+ # find what char to aggregate to the phrase based on the input and its
+ # position in the word.
+ chr = ""
+
+ if x[g]=="\n": {} #if this char is a new line, go to add new line def
+ elif x[g]=="\r": {} #if this char is carriage return, skip it.
+ elif x[g]=="{": chr="}" #dealing with parenthesis
+ elif x[g]=="}": chr="{"
+ elif x[g]=="(": chr=")"
+ elif x[g]==")": chr="("
+ elif x[g]=="ء": chr="ﺀ"
+
+ # dealing with letters, output each
+ # letter with its right position
+ elif x[g]=="آ": chr=alfmd[pos]
+ elif x[g]=="أ": chr=alfhz[pos]
+ elif x[g]=="ؤ": chr=wowhz[pos]
+ elif x[g]=="إ": chr=alfxr[pos]
+ elif x[g]=="ئ": chr=hamzk[pos]
+ elif x[g]=="ا": chr=alfff[pos]
+ elif x[g]=="ب": chr=baaaa[pos]
+ elif x[g]=="ة": chr=tamrb[pos]
+ elif x[g]=="ت": chr=taaaa[pos]
+ elif x[g]=="ث": chr=thaaa[pos]
+ elif x[g]=="ج": chr=geeem[pos]
+ elif x[g]=="ح": chr=haaaa[pos]
+ elif x[g]=="خ": chr=khaaa[pos]
+ elif x[g]=="د": chr=daaal[pos]
+ elif x[g]=="ذ": chr=thaal[pos]
+ elif x[g]=="ر": chr=raaaa[pos]
+ elif x[g]=="ز": chr=zaaai[pos]
+ elif x[g]=="س": chr=seeen[pos]
+ elif x[g]=="ش": chr=sheen[pos]
+ elif x[g]=="ص": chr=saaad[pos]
+ elif x[g]=="ض": chr=daaad[pos]
+ elif x[g]=="ط": chr=taaah[pos]
+ elif x[g]=="ظ": chr=daaah[pos]
+ elif x[g]=="ع": chr=aayen[pos]
+ elif x[g]=="غ": chr=gayen[pos]
+ elif x[g]=="ف": chr=faaaa[pos]
+ elif x[g]=="ق": chr=qaaaf[pos]
+ elif x[g]=="ك": chr=kaaaf[pos]
+ elif x[g]=="ل":
+ # dealing with (la combination)
+ # in this case the char has two chars in one
+ # so we should increment the counter (g)
+ g = g+1
+ if g == ln:
+ g = g-1
+ chr=laaam[pos]
+ elif x[g]=="ا": chr=laaaa[pos]
+ elif x[g]=="أ": chr=laahz[pos]
+ elif x[g]=="إ": chr=laaxr[pos]
+ elif x[g]=="آ": chr=laamd[pos]
+ else:
+ g = g-1
+ chr=laaam[pos]
+ elif x[g]=="م": chr=meeem[pos]
+ elif x[g]=="ن": chr=nooon[pos]
+ elif x[g]=="ه": chr=hhhhh[pos]
+ elif x[g]=="و": chr=wowww[pos]
+ elif x[g]=="ى": chr=yaamd[pos]
+ elif x[g]=="ي": chr=yaaaa[pos]
+ elif x[g]=="لآ": chr=laamd[pos]
+ elif x[g]=="لأ": chr=laahz[pos]
+ elif x[g]=="لإ": chr=laaxr[pos]
+ elif x[g]=="لا": chr=laaaa[pos]
+ #if the char is a symbol, add it
+ elif x[g] in sym:
+ # Special cases for escaped \" and \t
+ if x[g] == "\\" and g+1 < ln:
+ if x[g+1] == "\"":
+ chr="\\\""
+ g += 1
+ if x[g+1] == "t":
+ chr="\\t"
+ g += 1
+ else:
+ chr = x[g]
+ else:
+ chr = x[g]
+ #if the char is an arabic reversed letter, reverse it back!
+ elif x[g] in unicodec: chr=x[g]
+
+ # advance to the next char
+ g += 1
+ # add the char before the previous one
+ words = chr+words
+ return words
+
+def Start(fileR, fileW):
+ """Open the .po file and do a special reverse in the msgstr lines"""
+ fileR = open(fileR, "r",-1, "utf-8")
+ fileW = open(fileW, "w",-1, "utf-8")
+
+ inside_msgstr = False
+ inside_header = True
+
+ for line in fileR:
+ if inside_header:
+ fileW.write(line)
+ if line == "\n": inside_header = False
+
+ else:
+ if line.startswith("msgstr"):
+ strng = stripeol(line)[8:-1]
+ rslt = ProcessInput(strng)
+ fileW.write("msgstr \"{}\"\n".format(rslt))
+ inside_msgstr = True
+ elif inside_msgstr:
+ strng = stripeol(line)[1:-1]
+ if strng:
+ rslt = ProcessInput(strng)
+ fileW.write("\"{}\"\n".format(rslt))
+ else:
+ fileW.write(line)
+ inside_msgstr = False
+ else:
+ fileW.write(line)
+ inside_msgstr = False
+
+ fileR.close()
+ fileW.close()
+
+
+if __name__ == "__main__":
+ #argument parsing
+ import argparse
+ parser = argparse.ArgumentParser(description="Open the .po file and do " \
+ "a special reverse in the " \
+ "msgstr lines.")
+ parser.add_argument('input', help="Input .po file.")
+ parser.add_argument('output', default=None, help="Output .po file.")
+ args = parser.parse_args()
+
+ file_input = os.path.abspath(args.input)
+ if not file_input.endswith(".po"):
+ print("Error: Wrong file format. Use: `python3 ar_to_utf.py ar.po [ar_done.po]`")
+ exit()
+
+ # the last parameter is optional
+ if args.output:
+ file_output = os.path.abspath(args.output)
+ else:
+ file_output = "{}_done.po".format(file_input[:-3])
+
+ # parse the file
+ Start(file_input, file_output)
+
Added: branches/fa/fa_to_utf.py
===================================================================
--- branches/fa/fa_to_utf.py (rev 0)
+++ branches/fa/fa_to_utf.py 2011-10-20 20:58:44 UTC (rev 116)
@@ -0,0 +1,246 @@
+#coding: utf-8
+
+import sys
+import os
+
+
+def stripeol(s):
+ return s.rstrip("\n\r")
+
+
+# Isolated, Beginning, Middle, End
+# http://en.wikipedia.org/wiki/Persian_alphabet
+alefa = ["ﺁ","ﺁ","ﺂ","ﺂ"]
+alefd = ["ﺍ","ﺍ","ﺎ","ﺎ"]
+beeee = ["ﺏ","ﺑ","ﺒ","ﺐ"]
+peeee = ["ﭖ","ﭘ","ﭙ","ﭗ"]
+teeee = ["ﺕ","ﺗ","ﺘ","ﺖ"]
+seeee = ["ﺙ","ﺛ","ﺜ","ﺚ"]
+jimmm = ["ﺝ","ﺟ","ﺠ","ﺞ"]
+cheee = ["ﭺ","ﭼ","ﭽ","ﭻ"]
+heeee = ["ﺡ","ﺣ","ﺤ","ﺢ"]
+kheee = ["ﺥ","ﺧ","ﺨ","ﺦ"]
+daall = ["ﺩ","ﺩ","ﺪ","ﺪ"]
+zaall = ["ﺫ","ﺫ","ﺬ","ﺬ"]
+reeee = ["ﺭ","ﺭ","ﺮ","ﺮ"]
+zeeee = ["ﺯ","ﺯ","ﺰ","ﺰ"]
+zheee = ["ﮊ","ﮊ","ﮋ","ﮋ"]
+sinnn = ["ﺱ","ﺳ","ﺴ","ﺲ"]
+shinn = ["ﺵ","ﺷ","ﺸ","ﺶ"]
+saddd = ["ﺹ","ﺻ","ﺼ","ﺺ"]
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-translations-svn
mailing list