Open paulwalk opened 2 weeks ago
I am finding the
<br id=i18n />
in my translated locales. I understand from this recent commit that:
Line breaks are not kept when translating html content via Google Translate
Therefore we transform
\n
into a placeholder and then back aftertranslating
It is the "and then back after translating" part which does not seem to be working.
Could you try to write a test case which triggers it? Or try edit existing tests?
I'm afraid that I'm not competent to write a unit test for this, but I can offer an example that fails:
en.yml
---
en:
test_html_translation:
some_html: |-
<p>Each repository in this directory is characterised by the following features:</p>
<ul>
<li>The majority of its content is fully Open Access</li>
<li>It has a functioning OAI-PMH interface</li>
</ul>
Running i18n-tasks translate-missing
generates the following file (Spanish example):
es.yml
---
es:
test_html_translation:
some_html: "<p>Cada repositorio de este directorio se caracteriza por las siguientes características:</p><br id=i18n /><ul><br id=i18n /><li> La mayor parte de su contenido es totalmente de acceso abierto.</li><br id=i18n /><li> Tiene una interfaz OAI-PMH funcional</li><br id=i18n /></ul>"
I have just discovered that naming the key *_html
seems to be what triggers this.
So, running the same experiment, with a new key called some_text
, but containg the exact same content as some_html
, gives the following:
en.yml
---
en:
test_html_translation:
some_html: |-
<p>Each repository in this directory is characterised by the following features:</p>
<ul>
<li>The majority of its content is fully Open Access</li>
<li>It has a functioning OAI-PMH interface</li>
</ul>
some_text: |-
<p>Each repository in this directory is characterised by the following features:</p>
<ul>
<li>The majority of its content is fully Open Access</li>
<li>It has a functioning OAI-PMH interface</li>
</ul>
gives:
es.yml
---
es:
test_html_translation:
some_html: "<p>Cada repositorio de este directorio se caracteriza por las siguientes características:</p><br id=i18n /><ul><br id=i18n /><li> La mayor parte de su contenido es totalmente de acceso abierto.</li><br id=i18n /><li> Tiene una interfaz OAI-PMH funcional</li><br id=i18n /></ul>"
some_text: |-
<p>Cada repositorio de este directorio se caracteriza por las siguientes características:</p>
<ul>
<li>La mayor parte de su contenido es de acceso abierto completo</li>
<li>Tiene una interfaz OAI-PMH funcional</li>
</ul>
So, simply avoiding the use of keys ending in *_html
is enough to resolve this!
_html
is a special suffix in that it makes Rails automatically mark such values as html_safe
, so renaming the key is not ideal.
@davidwessman Can you please have a look?
I think the issue may be here:
There probably shouldn't be a space after #{NEWLINE_PLACEHOLDER}
.
I have been swamped, but it is on my list unless someone is faster than me!
@glebm Do you somehow have access to Google Translate API that I can use?
@paulwalk can you please try out https://github.com/glebm/i18n-tasks/pull/597?
I am finding the
<br id=i18n />
in my translated locales. I understand from this recent commit that:It is the "and then back after translating" part which does not seem to be working.