po translation files: what are automatic comments for? - translation

When I translate some stuff, sometimes there are strings that are put in comments and stay after everything else. What are those comments for?
For example:
#~ msgid ""
#~ "You tried to register but your email is already known.\n"
#~ "To try again to login, click on the following link:\n"
#~ "{}{}"
#~ msgstr ""
#~ "Vous avez essayé de vous enregistrer, mais votre email est déjà connu."
#~ "Pour vous connecter, cliquez sur le lien suivant :\n"
#~ "{}{}"
What is the ~ for?
Sometime there's a pipe like this:
#~| msgid "Show your activity"
#~ msgid "your activities"
#~ msgstr "Montrer mon activité"
What is the | for?

#~ comments are obsolete strings. When a string has translation but does not appear in the current template (.pot), the msgmerge tool will comment it out with #~, but leave it in.
If the string appears again in future, it will uncomment the translation again, so you won't have to retranslate it. It will also use thus commented entries as source for suggestions via fuzzy matching.
The #~| is a result of commenting out a #| comment. A #| comment is the original text when creating a suggestion via fuzzy matching. For example if the catalogue has
msgid "Open"
msgstr "Otevři"
and the template has
msgid "Open!"
msgstr ""
then msgmerge will create:
#,fuzzy
#| msgid "Open"
msgid "Open!"
msgstr "Otevři"
The po editors like poedit, pootle or weblate should remove the #| comment when the string is fixed and fuzzy flag removed. But if somebody edits the .po in a text editor, they may erroneously leave it in.

Related

Django translation files substitute msgid with another translation

I have a site that should be localized in different languages: English, French and Russian.
In russian po I have the following:
msgid "An error has occurred. Please reload the page."
msgstr "Произошла ошибка. Пожалуйста, перезагрузите страницу."
In french po:
msgid "An error has occurred. Please reload the page."
msgstr ""
The problem is that my french translator doesn't know English, it knows Russian.
How to solve this problem?
Is it possible to generate french po like:
msgid "Произошла ошибка. Пожалуйста, перезагрузите страницу."
msgstr ""
Thank you.

Is it possible to write shorthand in cakephp 3 translation files?

My src\Locale\pr_IR file is like
msgid "Mobile"
msgstr "موبایل"
msgid "mobile"
msgstr "موبایل"
msgid "MoBiLe"
msgstr "موبایل"
Is it possible to convert this to something like
msgid "Mobile"
msgid "mobile"
msgid "MoBiLe"
msgstr "موبایل"
No it's not, at least not without creating your own PO file parser that would handle such an invalid/non-standard PO format.
See also
Cookbook > Internationalization & Localization > Creating Message Parsers
http://www.gnu.org/software/gettext/manual/gettext.html#PO-Files
Multiple "msgid" for an "msgstr" in gettext

print msgid msgstr from po file to another file

I have a translated .po file. I like to extract msgid and msgstr to another file.. so that i can print it and give it for error checking to another person..
Here i need omit all the strings/newline/whitespace and space characters. i need only lines with msgid and msgstr
example input
**
#: ../src/administration-activity/admin/class_edit.py:56
msgid "Editing a Class"
msgstr "ತರಗತಿನ್ನು ಬದಲಾಯಿಸಲಾಗುತ್ತಿದೆ"
#: ../src/administration-activity/admin/class_edit.py:61
msgid "Editing class: "
msgstr "ಬದಲಾಯಿಲಾಗುತ್ತಿರುವ ತರಗ:"
**
required output
msgid "Editing a Class"
msgstr "ತರಗತಿನ್ನು ಬದಲಾಯಿಸಲಾಗುತ್ತಿದೆ"
msgid "Editing class: "
msgstr "ಬದಲಾಯಿಲಾಗುತ್ತಿರುವ ತರಗ:"
With Eazy Po you use Export Using Template to save the file the way you like. Open the po file, and from the File menu select Export -> Using Template. A Template Editor window will pop up:
In the left pane list right click for a popup menu and select New Template. In New Template dialog define your template name and press Ok.
In the Loop Block text box type the following (or copy & paste):
msgid "%source%"
msgstr "%translation%"
You will notice a sample result in the Result Example pane at the bottom of the window and this result will change instantly as you play with it.
Select Generate & Save button to save the generated file.
For escape characters substitution; see the setting for the other pre built templates.

How to clean up a string (email body) with regards to special characters?

I have an email extracted from an IMAP account. I have encoded it like this:
body = imap.uid_fetch(uid, "BODY[TEXT]")[0].attr["BODY[TEXT]"].force_encoding('UTF-8')
So now it looks like this:
puts body.inspect => "\n--Apple-Mail-028364EC-0K8B-4FD7-87E8-97C28C324717\nContent-Type: text/plain; charset=\"utf-8\"\nContent-Transfer-Encoding: quoted-printable\n\nHej=20\n\nI m=C3=A5 meget undskylde men jeg vil ikke k=C3=B8be produktet alligevel hvord=\nan g=C3=B8r vi det...=20\n\nHans Nielsen. =20\nR=C3=B8rgade 65=20\n1234 G=C3=B8rlev\n\n"
I want to present the email in my Rails app, so the user of the app can review the email. But how do I clean up the body?
I want to remove this part:
--Apple-Mail-028364EC-0K8B-4FD7-87E8-97C28C324717
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
And clean up this part:
Hej=20
I m=C3=A5 meget undskylde men jeg vil ikke k=C3=B8be produktet alligevel hvord=
an g=C3=B8r vi det...=20
Hans Nielsen. =20
R=C3=B8rgade 65=20
1234 G=C3=B8rlev
This means replacing the weird characters with the originally intended characters. Fyi, these are:
=C3=A5 is å
=C3=B8 is ø
=20 is ???
= is ???
How to do this (without just using gsub)?
You need to use a MIME parser, which should take care of removing the headers and getting rid of the quoted printable encoding. Depending on the layout of your email, body[text] might get you a lot more than you want. You need to either download the BODYSTRUCTURE and pick out the parts you want, or download the entire message (BODY[]) and use a MIME parser.
The decoding result is:
Hej
I må meget undskylde men jeg vil ikke købe produktet alligevel hvordan gør vi det...
Hans Nielsen.
Rørgade 65
1234 Gørlev
It seems that = is ... and =20 is "\n".

translation in quotes words using gettext

I need translate this sentence:
My name is "Josep", whar's your name?
In the po file, this sentence would be:
msgid "My name is "Josep", whar's your name?"
msgstr "El meu nom es "josep" Quin es el teu"
But this throw a error when I make the .mo file due to quotes inside josep name.
How can I scape this character?
I think you need to escape your " as \".

Resources