How use labels in transchoice() - symfony

I need to translate a french phrase depending of gender and quantity.
In message.fr.yml, I have :
key.toto: "male_singular: tu es venu 1 fois donc 1 vie|female_singular: tu es venue 1 fois donc 1 vie|male_plural: tu es venu %count% fois donc %count% vies|male_singular: tu es venue %count% fois donc %count% vies"
I see in doc of Symfony\Component\Translation\MessageSelector used by transchoice()
The indexed solution can also contain labels (e.g. one: There is one apple).
This is purely for making the translations more clear - it does not affect the functionality.
The two methods can also be mixed:
{0} There are no apples|one: There is one apple|more: There are %count% apples
But when I call transchoice With a call like that
transchoice("key.toto", "female_singular", array(), "messages")
I have :
"tu es venu 1 fois donc 1 vie"
instead of :
"tu es venue 1 fois donc 1 vie"
I prefer use labels instead of {} because messages files are translated by another enterprise.
Any idea ?

From Translation component documentation:
The tags are really only hints for translators and don't affect the
logic used to determine which plural form to use.
and
As tags are optional, the translator doesn't use them (the translator
will only get a string based on its position in the string).
You can make sure if you open the source code of transChoice() method:
public function transChoice($id, $number, array $parameters = array(), $domain = null, $locale = null)
{
...
return strtr($this->selector->choose($catalogue->get($id, $domain), (int) $number, $locale), $parameters);
}
As you can see, transChoice() casts the $number parameter to int.
Manual says that PHPconverts "female_singular" to 0:
<?php
echo (int) "female_singular"; //0
So when you do not specify the range in your transchoice string, Translation component make its choice based on the string position.
In your case(number = 0) it's the string: "tu es venu 1 fois donc 1 vie".

Related

Keyword: Selenium2Library.Wait Until Element Is Visible' expected 1 to 3 arguments, got 4

I'm trying to verify the name of the ticket with the RFW code below :
[Arguments] ${Ticket_lié}
Wait Until Element Is Visible xpath=//div[contains(#data-id,"dy_ticketlieid.fieldControl-LookupResultsDropdown_dy_ticketlieid_selected_tag")]//div[#title="COL-209464 - SI CREME "] ${TEMPS_MAX_ATTENTE_ELEMENT_VISIBLE} la valeur du champ Ticket lié n'est pas bonne**
Can anyone help me check what I'm missing here please .
My guess is that the problem stems from having more than one consecutive space in the xpath. You should escape the extra spaces.
... xpath=//...//div[#title="COL-209464 - \ SI CREME \ "]
^ ^

Translation keywords in second level not work

I am using the translator component of symfony, always i have used this component and its work correctly, but, in a new project, i have started to use this component and the second level of translations are not recognized for my debugging bar.
Example:
//messages.es.yml
#USUARIOS
usuarios:
gestion: Gestion de usuarios
listado: Listado de usuarios
nuevo: Nuevo usuario
Using translate in controller or twig:
//SomeController.php
$breadcrumbs->addRouteItem($this->get("translator")->trans("usuarios.nuevo"), "backend_usuario_register");
// someFile.html.twig
{{ "usuarios.nuevo" | trans }}
In both cases return: usuarios.nuevo
Where is the problem? :/
EDIT 1
Fixed, the problem was that the keyword 'usuarios' was defined above as: usuarios: Usuarios.
Now I have another problem, how can I give a value to the primary id so that it leaves without error?
I have it now, but it returns error:
//messages.es.yml
#USUARIOS
usuarios: Usuarios
gestion: Gestion de usuarios
listado: Listado de usuarios
nuevo: Nuevo usuario
Thank!

Sage CRM - Field with entry type 53 (Territory) is not available when creating a new field?

Im trying to create a field in the team entity to be able to select its zone/territory.
Looking in the DDBB i see that the field comp_secterr uses the entry type with id 53 (Entry type Territory) with this SQL
SELECT * FROM Custom_Edits WHERE ColP_ColName LIKE ('comp_secterr');
but when creaing a new field, in the select, there is not option to choose the Entry Type 53
<select class="EDIT" size="1" name="entrytype" id="entrytype" onchange="document.EntryForm.hiddenmode.value=1;document.EntryForm.submit();"><option value="15">Texto con búsqueda de casilla de verificación</option><option value="25">Producto</option><option value="27">Selección inteligente</option><option value="28">Selección múltiple</option><option value="42">Fecha sólo</option><option value="51">Divisa</option><option value="56">Selección de búsqueda avanzada</option><option value="57">Minutos</option><option value="59">Símbolos de las monedas</option><option value="63">Selección de grupo de usuarios</option><option value="10" selected="">Texto</option><option value="44">Procedimiento almacenado</option><option value="45">Casilla</option><option value="50">Número de teléfono</option><option value="11">Texto MultiLínea</option><option value="12">Dirección de correo electrónico</option><option value="13">URL WWW</option><option value="21">Selección</option><option value="22">Selección de usuario</option><option value="23">Selección de Equipo</option><option value="31">Número entero</option><option value="32">Numérico</option><option value="41">Fecha y hora</option></select>
Entry Type 53 is reserved for Territory fields, but is not accessible via the front-end. To use it, you need to update the Custom_Edits table directly using a query similar to this:
UPDATE custom_Edits SET colp_entrytype = 53 WHERE ...
Make sure you do a full metadata refresh after as well.
While it is not absolutely necessary, it is also good for consistency to name Territory fields _secterr (E.g. comp_secterr)
Six Ticks Support

Encoding issues with Disqus API results (2 Unicode characters which should be interpreted as one)

I have got a Qt application which receive strings in JSON objects from the Disqus API:
{ "title": "Swiftkey pr\u0102\u0160dit votre choix d\u2019emoji gr\u0102\u02d8ce au clavier Swiftmoji" }
(there's more but I only write what matters here)
Then I put the title string in a QString:
// Assuming that "reply" is the QNetworkReply * containing the Disqus API response.
QByteArray disqusReply = reply->readAll();
// disqusReply == "{ \"title\": \"Swiftkey pr\u0102\u0160dit votre choix d\u2019emoji\ gr\u0102\u02d8ce au clavier Swiftmoji" }"
QJsonDocument doc = QJsonDocument::fromJson(disqusReply);
QJsonObject obj = doc.object();
QString title = obj["title"].toString();
Later I write it in a QML Text. It should display "Swiftkey prédit votre choix d'emoji grâce au clavier Swiftmoji" but it displays "Swiftkey prĂŠdit votre choix d'emoji grâce au clavier Swiftmoji" instead.
As you can see there are some encoding issues, with two successive Unicode characters which should be interpreted as one character only ("ĂŠ" instead of "é" and "â" instead of "à" here). How can I do (with Qt or QML) to display the right characters? Which encoding conversions I have to perform (with Qt or QML) in order to solve those encoding issues?
Additional informations: the bug occurs on Windows 10 64-bit.
EDIT : you can find the bug here: https://disqus.com/api/3.0/threads/list.json?since=2016-05-18T14%3A08%3A27%2B00%3A00&forum=frandroid&api_key=7o0xSBOEzN2AG6yxcJgeJbeEbACBfGhgnoIRHu7umbifKAvXQpisYKT3KSXF9nPN
Well, I think the problem in double encoding or something else from server side, not from client's. Because your code must be pr\u00e9dit instead of pr\u0102\u0160dit. If you'll use clean_title instead of title of your json-answer you'll get the right string cause it's encode is correct.
UPD:
As I said in comment - there are two replies with same news. Id 4836688567 has wrong encode string. And 4836587900 correct. There are many double variants of news with different encoding.
First:
{
"feed":"https://frandroid.disqus.com/httpwwwfrandroidcomandroidapplications358721_swiftkey_predire_choix_demoji_grace_clavier_swiftmoji/latest.rss",
"identifiers":[],
"dislikes":0,
"likes":0,
"message":"",
"id":"4836688567",
"createdAt":"2016-05-18T09:08:43",
"category":"448171",
"author":"3938134",
"userScore":0,
"isSpam":false,
"signedLink":"http://disq.us/?url=http%3A%2F%2Fwww.frandroid.com%2Fandroid%2Fapplications%2F358721_swiftkey-predire-choix-demoji-grace-clavier-swiftmoji&key=nqCbe6jgfwM-skLyqTf3lg",
"isDeleted":false,
"raw_message":"",
"isClosed":false,
"link":"http://www.frandroid.com/android/applications/358721_swiftkey-predire-choix-demoji-grace-clavier-swiftmoji",
"slug":"httpwwwfrandroidcomandroidapplications358721_swiftkey_predire_choix_demoji_grace_clavier_swiftmoji",
"forum":"frandroid",
"clean_title":"Swiftkey pr\u0102\u0160dit votre choix d\u2019emoji gr\u0102\u02d8ce au clavier Swiftmoji",
"posts":0,
"userSubscription":false,
"title":"Swiftkey pr\u0102\u0160dit votre choix d\u2019emoji gr\u0102\u02d8ce au clavier Swiftmoji",
"highlightedPost":null
}
Second:
{
"feed":"https://frandroid.disqus.com/swiftkey_predit_votre_choix_d8217emoji_grace_au_clavier_swiftmoji/latest.rss",
"identifiers":["358721 http://www.frandroid.com/?p=358721"],
"dislikes":0,
"likes":1,
"message":"",
"id":"4836587900",
"createdAt":"2016-05-18T08:16:30",
"category":"448171",
"author":"3938134",
"userScore":0,
"isSpam":false,
"signedLink":"http://disq.us/?url=http%3A%2F%2Fwww.frandroid.com%2Fandroid%2Fapplications%2Fgoogle-apps%2F358721_swiftkey-predire-choix-demoji-grace-clavier-swiftmoji&key=UU8IrLN_UDXEggF6wHjAYg",
"isDeleted":false,
"raw_message":"",
"isClosed":false,
"link":"http://www.frandroid.com/android/applications/google-apps/358721_swiftkey-predire-choix-demoji-grace-clavier-swiftmoji",
"slug":"swiftkey_predit_votre_choix_d8217emoji_grace_au_clavier_swiftmoji",
"forum":"frandroid",
"clean_title":"Swiftkey pr\u00e9dit votre choix d\u2019emoji gr\u00e2ce au clavier Swiftmoji",
"posts":13,
"userSubscription":false,
"title":"Swiftkey pr\u00e9dit votre choix d’emoji gr\u00e2ce au clavier Swiftmoji",
"highlightedPost":null
}
As you see, difference in url from where news comes. But why some of them encoded wrong - this is a question.
UPD 2:
Or maybe it's RSS bug. Let's take prédit word. In second variant RSS returns xml with content which has been already encoded to é and feed link looks like normal. In first variant RSS returns ĂŠ and its feed link looks like anormal - feel like it takes whole url and do another encode.
Have you tried
QByteArray disqusReply
= QString::fromUtf8(reply->readAll().data()).toLocal8Bit();
? You might prefer delaying this conversion until actually writing the string into the QML text.
QJsonDocument requires UTF-8 encoded strings. Is your document encoded in UTF-8 when you load it?

asp:localize not working to translate

I have the following somewhere in a page:
<asp:Localize ID="locChangePasswordPrompt" runat="server"
Text="Change Your Password" meta:resourcekey="locChangePasswordPrompt" />
I am localizing using sql server database and I have stored the FRENCH corresponding values in the db.
Do if u do a query:
SELECT TOP 1000 [ResourceType]
,[CultureCode]
,[ResourceKey]
,[ResourceValue]
,[Preserve]
FROM [CLeX].[dbo].[StringResource]
where resourcekey like 'locChangePasswordPrompt%'
You get the values:
ResourceType CultureCode ResourceKey ResourceValue Preserve
common/UserPreferences.aspx en locChangePasswordPrompt 1
common/UserPreferences.aspx en locChangePasswordPrompt.Text Change Your Passwordss 1
common/UserPreferences.aspx en-US locChangePasswordPrompt 1
common/UserPreferences.aspx en-US locChangePasswordPrompt.Text Change Your Passwordss 1
common/UserPreferences.aspx fr locChangePasswordPrompt 1
common/UserPreferences.aspx fr locChangePasswordPrompt.Text Changez votre mot de passe 1
However, I am still not able to get the FRENCH values at all. In fact, not even the English values are being pulled from the DB. Localize simply pulls the text from its text attribute.
What could possibly be the reason?
Did you configure your DB Resource Provider?

Resources