Reputation: 33
I'm using Custom translator to translate Russian text into English. Some sentences contain \n
character that means newline. And my goal is to translate the text like there are no newlines in it, but I want to preserve this \n
.
Example russian:
очередь, к которой отнесен обработчик и в которой зарегистрированы данные, которые он будет обрабатывать.
English translation:
queue to which the handler is assigned and in which the data that it will process is registered
This text can have \n
in different places:
очередь, к которой отнесен обработчик и в которой зарегистрированы данные, которые он будет
\n
обрабатывать. очередь, к которой отнесен обработчик и в которой зарегистрированы данные\n
которые он будет обрабатывать. очередь, к которой отнесен обработчик и в которой\n
зарегистрированы данные, которые он будет обрабатывать.
And all translations should match the first one, but preserving the '\n' position.
Is it possible? I've tried to replace \n
with <BR>
or with
but the translation is different.
Upvotes: 0
Views: 1513
Reputation: 121
I could not find an elegant way of doing it. But, found a workaround. You can replace the "\n" with some word or characters from a completely different script and the translator keep it as it is, without having any effect on the translation. After you get back the translated text you can replace your dummy word with "\n".
I translated
очередь, к которой отнесен обработчик и в которой зарегистрированы данные, которые он будет मुखपृष्ठ обрабатывать. очередь, к которой отнесен обработчик и в которой зарегистрированы данные मुखपृष्ठ которые он будет обрабатывать. очередь, к которой отнесен обработчик и в которой मुखपृष्ठ зарегистрированы данные, которые он будет обрабатывать.
and it gave me
the queue to which the handler is assigned and where the data that it will मुखपृष्ठ process is recorded. the queue to which the handler is assigned and in which the data मुखपृष्ठ which it will process is recorded. the queue to which the handler is assigned and in which the मुखपृष्ठ recorded the data that it will process.
Here I have used a "hindi" word "मुखपृष्ठ" but you can probably try with something like Japanese or something.
Just to repeat, this is just a workaround that I have found to be working at this moment, don't know if this is good enough for all kinds of use cases or if it continue to work in future.
Upvotes: 0