Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP gettext reverse translate
    primarykey
    data
    text
    <p>My question is quite simple, I use gettext to translate URLs, therefore I only have the translated version of the url string.</p> <p>I would like to know if there was an easy way to get the base string from the translated string?</p> <p>What I had in head was to automatically add the translated name in a database and aliases it with the base string each times I use my <code>_u($string)</code> function.</p> <p>What I have currently:</p> <pre><code>function _u($string) { if (empty($string)) return ''; else return dgettext('Urls', $string); } </code></pre> <p>What I was thinking about (pseudo-code):</p> <pre><code>function _u($string) { if (empty($string)) return ''; $translation = dgettext('Urls', $string); MySQL REPLACE INTO ... base = $string, translation = $translation; (translation = primary key) return $translation; } function url_base($translation) { $row = SELECT ... FROM ... translation = $translation; return $base; } </code></pre> <p>Although it doesn't seem to be the best way possible to do this and, if on production I remove the <code>REPLACE</code> part, then I might forget a link or two in production that I might haven't went to.</p> <p>EDIT: What I am mostly looking for is the parsing part of gettext. I need not to miss any of the possible URLs, so if you have another solution it would be required to have a parser (based on what I'm looking for).</p> <p>EDIT2: Another difficulty have just been added. We must find the URL in any translations and put it back into the "base" translation for the system to parse the URL in the base language.</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.
 

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