Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You do not need to touch the system files/directories. And you should not touch them if you are developing.</p> <p>I tried the following code:</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;locale.h&gt; #include &lt;libintl.h&gt; int main(int argc, char **argv) { setlocale(LC_ALL, ""); bindtextdomain("main", "."); textdomain("main"); printf(gettext("Hello world\n")); return (0); } </code></pre> <p>Which is quite similar to your code, except I am testing the localization in my development directory (current one).</p> <p>Create the template for translations</p> <pre><code>$ xgettext -o main.pot main.c </code></pre> <p>Create the files to translate using the template:</p> <pre><code>$ msginit --no-translator -l es -o es.po -i main.pot Created es.po. $ msginit --no-translator -l fr -o fr.po -i main.pot Created fr.po. </code></pre> <p>Edit and translate the files. Set <em>Project-Id-Version</em> to <em>main</em> and translate the lines. In this case, the line 23 according to my source code.</p> <p>Create the target directories for translations:</p> <pre><code>$ mkdir -p es/LC_MESSAGES $ mkdir -p fr/LC_MESSAGES </code></pre> <p>Compile and install the translations:</p> <pre><code>$ msgfmt -o es/LC_MESSAGES/main.mo es.po $ msgfmt -o fr/LC_MESSAGES/main.mo fr.po </code></pre> <p>Compile the program:</p> <pre><code>$ make main cc main.c -o main </code></pre> <p>Run the program:</p> <pre><code>$ LANGUAGE=C ./main Hello world $ LANGUAGE=es ./main Hola mundo $ LANGUAGE=fr ./main Bonjour tout le monde </code></pre> <p>That is.</p> <p>You might want to compile the program before and fix errors, before translating it.</p>
    singulars
    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.
    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