Op Ma, 2011-03-28 om 11:42 +0200 skryf Nick Ruiz:
> Hello,
>
> I'm writing some back-end code to automate translations. I would like to
> populate a Unit object with a target multistring. I would like to learn
> more about the multistring object in relation to translations;
> unfortunately, the API doesn't provide me with enough information about
> the behavior of multistrings.
>
> How should I create a multistring to store a translation? Should I
> construct it with the following:
>
> s = "hello world"
> ms = multistring(s)
>
> What about multiple translations? Is this correct?
> ss = ["hello world", "hi world", "hello earth"]
> ms = multistring(ss)
>
> How do I access each of the translations? If I use ms.strings, I get the
> following:
>
> [multistring([u'hello world',u'hi world',u'hello earth']), u'hi world',
> u'hello earth']
>
> I see that I can get the alternative translations by referencing
> ms.strings[1] and ms.strings[2], but how should I access the first
> string (e.g. "hello world")? If I use unicode(ms), I can get "hello
> world", but is this the best approach?
>
> If I want to add another translation, should I use ms.strings.append("hi
> earth")?
>
> What are your recommendations for best practices for working with
> multistring? I want to make sure that my code follows the use of your
> patterns correctly.
Hallo Nick
Most of what you write looks correct. You can construct a multistring
with a list or another multistring if you want plurals. A simple string
gives you a multistring with a single (singular only) entry.
ms.strings[0] is always just ms itself. Not sure it is important or
useful in itself, but that is the way it is. Casting to Unicode is a
good approach as you suggest.
In general I wouldn't use ms.strings.append, but assign a new
multistring initialised with a list to .source or .target or similar. It
might just be a bit safer, I think.
Keep well
Friedel
--
Recently on my blog:
http://translate.org.za/blogs/friedel/en/content/better-lies-about-gnome-localisation
------------------------------------------------------------------------------
Enable your software for Intel(R) Active Management Technology to meet the
growing manageability and security demands of your customers. Businesses
are taking advantage of Intel(R) vPro (TM) technology - will your software
be a part of the solution? Download the Intel(R) Manageability Checker
today! http://p.sf.net/sfu/intel-dev2devmar
_______________________________________________
Translate-pootle mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/translate-pootle