Position of words in sprintf strings for translation - internationalization

In some languages, the words do not have the same position.
Here is an example:
sprintf( __( '%s left a %s on %s\'s %s.', 'o2' ), $commentAuthor, $commentLink, $postAuthor, $postLink );
This string returns for example:
John(1) left a comment(2) on Jane(3)'s post(4).
But in French, some words are not in the same position:
John(1) a laissé un commentaire(2) sur la publication(4) de Jane(3).
I translated the string in poedit:
%s a laissé un %s sur la %s de %s.
But the words are misplaced:
John(1) a laissé un commentaire(2) sur la Jane(3) de publication(4).
This is not a correct translation.
How to change the order with poedit or any other translation editor?

Well, I finally found the solution:
sprintf( __( '%1$s left a %2$s on %3$s\'s %4$s.', 'o2' ), $commentAuthor, $commentLink, $postAuthor, $postLink );
In poedit:
%1$s a laissé un %2$s sur la %4$s de %3$s.

Related

sphinx gettext inserts empty quotes "" in front of previously matching msg

Currently my worflow when I change things in the original file is this:
make gettext to update *.pot files
sphinx-intl update -p build/gettext -l fr to create *.po files out of it
However, this always results in the following behavior: Some longer messages in the *.po files are not correctly updated or to be more correct they are updated although they didn't change. sphinx-intl update will insert quotes "" in front of every paragraph that spans over multiple lines. Here's how that looks:
Before: (in some french *.po file):
msgid "Some longer paragraph text that spans multiple lines. This text was just"
"lying here and matched a sequence within the file before gettext inserted"
"unnecessary quotes on top."
msgstr "Un texte de paragraphe plus long qui s'étend sur plusieurs lignes. Ce texte se trouvait juste ici et correspondait à une séquence dans le fichier avant que gettext n'insère des guillemets inutiles par-dessus."
After:
msgid ""
"Some longer paragraph text that spans multiple lines. This text was just"
"lying here and matched a sequence within the file before gettext inserted"
"unnecessary quotes on top."
msgstr ""
"Un texte de paragraphe plus long qui s'étend sur plusieurs lignes "
"Ce texte se trouvait juste ici et correspondait à une séquence dans le "
"fichier avant que gettext n'insère des guillemets inutiles par-dessus."
This is extremely annoying as it will not match anymore with the text it is supposed to! Only when I remove the leading "" the texts will match again. I wondered if this happens because I tend write my translated msgstr as one line without intermitted quotes (what are they good for anyway?). After sphinx-intl update they are enclosed in quotes...
What is going on and how can I prevent this?

How to check the value of several variables in a th: text thymeleaf

I find a lot of tutorial to check if a variable is null or not in a th: text.
But I can not find to check several, and change the text.
here is my example:
th:text="|${item?.startDate} ${item?.endDate} ${item?.startTime} ${item?.endTime}|"
See that sometimes one or more of its 4 variables can be null, so sometimes I have null displayed.
I therefore want to display
From XX to YY at 10 a.m. until 7 p.m.
And if possible, be able to use the locales 'From' 'To' 'to' and 'to' so that this line is multi-lingual.
Precision:
I use internalization well:
message1= Starts on(en), Débute le (fr)
message2= Ends on( en), se termine le (fr)
message 3= begins to (en), commence à(fr)
message4= finishes at (en), se termine à (fr)
So I want to Show
Fr: Débute le item.startDate se termine le item.endDate commence à item.startTime se termine à item.endTime
en: Starts on item.startDate ends on item.endDate begins to item.startTime finishes at item.endTime
but the problem is that sometimes I have item.startTime and / or item.endTime which is / are null
So I want to display the message partially:
Fr: Débute le item.startDate se termine le item.endDate
en: Starts on item.startDate ends on item.endDate
And sometimes I can have item.startTime and item.endTime not null but item.startDate and item.endDate null
So I will want to display the following message:
Fr: commence à item.startTime se termine à item.endTime
en: begins to item.startTime finishes at item.endTime
I can't find the correct syntax for this example
thanking you

Explanation of error using "color" in a batch script

In order to set the color of a batch script's console/terminal, color can be used. E.g. color 70. However, in order to reset the color of a the console, color without any arguments/values can be used. What is causing confusion for me is why it only works inside the command prompt or a called script but not a script started specifically with cmd /c. It fails and returns an errorcode of 1. Is there some legacy reason for this or is it a bug in Windows?
cmd /c color || echo foobar
Output: foobar
Expected output:
cmd /c color 70 || echo foobar
Output:
Expected output:
call color || echo foobar
Output:
Expected output:
To have no error, try to put the default color, as you said,
the color of a the console
That means the default color, I gess, so put color 07, to switch to color black-light grey.
For more info for colors in a .bat file create a .bat file and put in it color h, only this, save it and run it. It will give you all the info about colors.
If you are not able to do this, here is what it will show you. (Sorry, it's in french, but I gess you can understand)
Change les couleurs par défaut du premier et de l'arrière plan de la console.
COLOR [attr]
attr Spécifie les attributs de couleurs de l'apparence de la console
Les attributs de couleurs sont spécifiés par DEUX chiffres hexadécimaux -- le
premier correspond à l'arrière plan, le second au premier plan. Chaque chiffre
peut prendre n'importe quelle de ces valeurs :
0 = Noir 8 = Gris
1 = Bleu foncé 9 = Bleu clair
2 = Vert A = Vert clair
3 = Bleu-gris B = Cyan
4 = Marron C = Rouge
5 = Pourpre D = Rose
6 = Kaki E = Jaune
7 = Gris clair F = Blanc
Si aucun argument n'est donné, cette commande restaure les couleurs
sélectionnées au moment où CMD.EXE a été ouvert. Cette valeur vient soit de la
fenêtre de la console, du commutateur en ligne de commande /T, ou de la valeur
DefaultColor du registre.
Appuyez sur une touche pour continuer...
Again, sorry that is in french
Kalolol

convert certain special characters to ascii in php

I need a php script that convert certain special characters to ascii code( , . / - and all the letter with accent)
eg.
original:
Dingo a accidentellement fait tomber la pièce porte-bonheur de Mickey tout au fond du lac. Le Professeur Von Drake va utiliser son camping-car et le transformer en sous-marin pour explorer les eaux profondes.
result:
Dingo a accidentellement fait tomber la pièce porte-bonheur de Mickey tout au fond du lac. Le Professeur Von Drake va utiliser son camping-car et le transformer en sous-marin pour explorer les eaux profondes.
I've tried htmlspecialchars() doesn't seems work out it only convert the characters which are special significance in HTML
If you look at the documentation of htmlspecialchars() you will see:
If you require all input substrings that have associated named entities to be translated, use htmlentities() instead.

JSON string decode

I receive a JSON object as :
Pots veure bé les anotacions que tenen accents? O caràcters "estranys"? Tipus l'ampersand &, les cometes ", les u's amb dièresis ü, apòstrofs ' i coses així?","numAnotacions"
when really is :
Pots veure bé les anotacions que tenen accents? O caràcters "estranys"? Tipus l'ampersand &, les cometes ", les u's amb dièresis ü, apòstrofs ' i coses així?","numAnotacions"
So, I don´t find the way to decode the string. I get the string :
NSString *responseString = [request responseString];
Please anyone can help me ?
Thanks
I thing JSONKit can help with parsing JSON (example).

Resources