← Back to team overview

openshot.developers team mailing list archive

Re: How to update translations template

 

After you have strings marked as 'translatable', you can manually add the
string to the POT file (which I wouldn't recommend), or you can run a
command (or 2) to generate the POT file (from all the .py files and XML /
glade files):

I'm attaching some instructions (and commands) I wrote (on the
/language/language_init.py) file.

Good luck!
-Jonathan

On Sun, Sep 20, 2009 at 1:44 PM, Andy Finch
<we.rocked.in79@xxxxxxxxxxxxxx>wrote:

> Hi Helen,
>
> To make a string translatable, you need to enclose it with _(), so
> "Desktop" becomes _("Desktop"). I expect there is a script that is run that
> creates/updates the translation template (I'm sure Jonathan can explain that
> part) , but you need to make sure the string is enclosed as above for the
> script to include it.
>
> Hope this helps,
> Andy.
>
> 2009/9/20 Helen McCall <wildnfree@xxxxxxxxxxxxxxxx>
>
>> Hello Jonathan,
>>
>> I am trying to fix
>>
>>
>> [Bug 433140] Re: 0.9.34: warning
>> when exporting a video or saving a
>> project
>>
>> All it needs is for Line 52 of classes/project.py to have the string
>> "Desktop" included in the translations template and have it then added
>> to the .po files.
>>
>> I am unsure of how to edit the translations template in a way which will
>> not break the system.
>>
>> Can you please brief me on how I do this so I can do it in future if any
>> other similar bugs arise, and also to help me learn how to add the
>> Help-Manual series to the translations system?
>>
>> Many thanks,
>>
>> Helen
>>
>>
>>
>>
>> _______________________________________________
>> Mailing list: https://launchpad.net/~openshot.developers<https://launchpad.net/%7Eopenshot.developers>
>> Post to     : openshot.developers@xxxxxxxxxxxxxxxxxxx
>> Unsubscribe : https://launchpad.net/~openshot.developers<https://launchpad.net/%7Eopenshot.developers>
>> More help   : https://help.launchpad.net/ListHelp
>>
>
>
#   ----------------------------- EXAMPLE CODE ----------------------------
#   Use this snippet on any module that needs to support translations.  Once this 
#   snippet is in place, you can use the _("") method to set all your strings.
#
#	   import language.Language_Init as Language_Init
#
#	   # Add this to each method that needs to translate strings
#	   _ = Language_Init.Translator().lang.gettext
#
#	   # To mark a string as 'translatable', use this syntax:
#	   MyString = _("Here is my string")



# ----------------------- Translation Example Commands --------------------
# To translate this program, you must create a POT (template) file, then a
# PO file (Ascii), then a MO file (binary), and then add it to the correct
# locale folder in the /locale/{CODE}/LC_MESSAGES/ folder.
#
# COMMANDS
# ------------------------------------------------------------------------
# Command to create the POT Template file, recursively for all .py files in the /openshot/ project.
# Create these 3 empty files.  Be sure they are empty:  
#       1) ~/openshot/main/locale/OpenShot/OpenShot_source.pot
#       2) ~/openshot/main/locale/OpenShot/OpenShot_glade.pot
#       3) ~/openshot/main/locale/OpenShot/OpenShot.pot
#
#		$ find ~/openshot/ -iname "*.py" -exec xgettext -j -o ~/openshot/main/locale/OpenShot/OpenShot_source.pot --keyword=_ {} \;
#		$ find ~/openshot/ -iname "*.glade" -exec xgettext -j -o ~/openshot/main/locale/OpenShot/OpenShot_glade.pot --keyword=translatable {} \;

# Command to combine the 2 pot files into 1 file
#       $ msgcat ~/openshot/main/locale/OpenShot/OpenShot_source.pot ~/openshot/main/locale/OpenShot/OpenShot_glade.pot -o ~/openshot/main/locale/OpenShot/OpenShot.pot


# Command to create the individual language PO files (Ascii files)
#		$ msginit --input=OpenShot.pot --locale=fr_FR
#		$ msginit --input=OpenShot.pot --locale=es

# Command to update the PO files (if text is added or changed)
#		$ msgmerge en_US.po OpenShot.pot -U
#		$ msgmerge es.po OpenShot.pot -U

# Command to compile the Ascii PO files into binary MO files
#		$ msgfmt en_US.po --output-file=en_US/LC_MESSAGES/OpenShot.mo
#		$ msgfmt es.po --output-file=es/LC_MESSAGES/OpenShot.mo

# OR, install POedit (http://www.poedit.net/), and open the .PO files with this program.  
# It let's you type the translations, saves the .PO file, and it automatically creates the .MO files
# for you.  Very nice.

# Then rename and copy the MO files into the /locales/{en_us/es/fr/etc}/LC_MESSAGES/OpenShot.mo
# NOTE:  BE SURE TO RENAME THE FILE = OpenShot.mo

# Command to Launch Program in any language
# LANG=es python OpenShot.py
#
# *** TROUBLESHOOTING TIPS:  If you get the following error: 
# (process:27990): Gtk-WARNING **: Locale not supported by C library. Using the fallback 'C' locale.
# 
# SOLUTION:  Step 1) Modify this file and add your language: /var/lib/locales/supported.d/local
#            Step 2) sudo dpkg-reconfigure locales
#            Step 3) Be sure the correct translation file localted at /usr/local/share/openshot/main/language/
#               NOTE:  fr <> fr_FR.  You must match the language code exactly.
# -------------------------------------------------------------------------


References