It is currently Sat Jul 06, 2024 8:29 pm


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Internationalizaion, localization (I18N, L10N)
PostPosted: Sat Mar 04, 2017 7:40 pm  (#1) 
Offline
GimpChat Member
User avatar

Joined: Jan 30, 2017
Posts: 19
Hello there,
I am writing scripts for work, and I need to make them available in various languages. I have worked something out, but I saw that Gimp proposed tools with gettext, N_ etc...

Does someone know what is the right way to make an i18n of your python script ?

Here is what I have worked out :
from gimpfu import *
from math import pi
from cmath import phase
from os import environ

txts = {
  'message no path' : {
    'en':'No path selected',
    'fr':'Aucun chemin selectionne',
    'es':'No hay ninguna ruta seleccionada'},
  'message no txt along path' : {
    'en':'Text along path plugin required, v0.4 recomanded',
    'fr':'Plugin Text along path requis, v0.4 recommande',
    'es':'Se necesita el plugin Text along path, mejor v0.4'},
  'short description quick arrow' : {
    'en':'Create an arrow from a vector',
    'fr':'Cree une fleche a partir d un chemin',
    'es':'Crea una flecha con un camino'},
  'long description quick arrow' : {
    'en':'Create an arrow from a vector without options',
    'fr':'Cree une fleche a partir d un chemin sans demander d option',
    'es':'Crea una flecha con un camino sin optiones'},
  'short description arrow' : {
    'en':'Create an arrow from a vector',
    'fr':'Cree une fleche a partir d un chemin',
    'es':'Crea una flecha con un camino'},
  'long description arrow' : {
    'en':'Create an arrow from a vector with options',
    'fr':'Cree une fleche a partir d un chemin avec des options',
    'es':'Crea una flecha con un camino con optiones'},
  'option text' : {
    'en':'Text',
    'fr':'Texte',
    'es':'Texto'},
  'option shaft width' : {
    'en':'Width of the shaft',
    'fr':'Largeur de la tige',
    'es':'Ancho del eje'},
  'option spike ratio' : {
    'en':'Size of the head (times the shaft)',
    'fr':'Taille de la pointe p/r a la tigh',
    'es':'Tamano de la flecha x el eje'},
  'option color 1' : {
    'en':'Color of the arrow',
    'fr':'Couleur de la fleche',
    'es':'Color de la flecha'},
  'option is border' : {
    'en':'With border?',
    'fr':'Avec bord ?',
    'es':'Con borde?'},
  'option color 2' : {
    'en':'Color of border and text',
    'fr':'Couleur du bord et du text',
    'es':'Color del borde y del texto'}
  }

language = environ['LANGUAGE']
default_language = "en"
   
txt = {}
for (key, val) in txts.items():
    if val.has_key(language):
        txt[key] = val[language]
    else:ñ
        txt[key] = val[default_language]


I have an issue with the environ['LANGUAGE'] value : on my window desk computer it is "es" for Spanish, and on my laptop it is "es_CO:es". I guess the part before the semicolon is relative to the country and the part after is relative to the language. Someone knows the formate of this variable ? if not could you write in your gimp python console the lines
import os
os.environ['LANGUAGE']

and give me the output ?


Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: Internationalizaion, localization (I18N, L10N)
PostPosted: Sun Mar 05, 2017 12:45 am  (#2) 
Offline
Script Coder
User avatar

Joined: May 07, 2014
Posts: 4003
Location: Canada
on mine:
>>> import os
>>> os.environ['LANGUAGE']
'en_US'
>>>

looks like you have to consider the first 2 characters to me.

_________________
TinT


Top
 Post subject: Re: Internationalizaion, localization (I18N, L10N)
PostPosted: Sun Mar 05, 2017 5:51 pm  (#3) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4756
A standard "locale" is made of two or three parts; the first is the language, the second is a language variant (often related to a "territory"), and the (optional) third is the codeset used. Of course Windows has a genetic phobia of standards...

The "variant" includes things such as a monetary units, date formats, etc... but can also include different spellings (for instance en_US and en_GB). es_CO is, I would guess, Spanish as spoken/used in Colombia.

_________________
Image


Top
 Post subject: Re: Internationalizaion, localization (I18N, L10N)
PostPosted: Mon Mar 06, 2017 2:29 pm  (#4) 
Offline
GimpChat Member
User avatar

Joined: Jan 30, 2017
Posts: 19
ofnuts wrote:
Of course Windows has a genetic phobia of standards...
:hehe sadly

ok so the code

language = environ['LANGUAGE']
language = language.split("_")[0]


should give me the language identification I want I think


Top
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]



* Login  



Powered by phpBB3 © phpBB Group