Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>gettext was designed to translate English text to other languages, and this is the way you should use it. Do not use it with keys. If you want keys, use some other technique such as an associative array.</p> <p>I have managed two large open-source projects (50 languages, 5000 translations), one using the key approach and one using the gettext approach - and I would never use the key approach again.</p> <p>The cons include propagating changes in English text to the other langauges. If you change</p> <pre><code>msg_no_food = "We had no food left, so we had to eat the cats" </code></pre> <p>to</p> <pre><code>msg_no_food = "We had no food left, so we had to eat the cat's" </code></pre> <p>The new text has a completely different meaning - so how do you ensure that other translations are invalidated and updated?</p> <p>You mentioned having long text that makes your scripts hard to read. The solution to this might be to put these in a separate script. For example, put this in the main code</p> <pre><code>print help_message('help_no_food') </code></pre> <p>and have a script that just provides help messages:</p> <pre><code>switch ($help_msg) { ... case 'help_no_food': return gettext("We had no food left, so we had to eat the cat's"); ... } </code></pre> <p>Another problem for gettext is when you have a full page to translate. Perhaps a brochure page on a website that contains lots of embedded images. If you allow lots of space for languages with long text (e.g. German), you will have lots of whitespace on languages with short text (e.g. Chinese). As a result, you might have different images/layout for each language.</p> <p>Since these tend to be few in number, it is often easier to implement these outside gettext completely. e.g.</p> <pre><code>brochure-view.en.php brochure-view.de.php brochure-view.zh.php </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload