My .po file contains:
"X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;"
"_n_noop:1,2;_c,_nc:4c,1,2;_x:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2;_ex:1,2c;"
"esc_attr__;esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c\n"
And my php/wordpress code contains:
_x( 'Add New', $this->post_type , $domain ),
I know that Poedit is scanning that file (all the other translatable strings are picked up on "update catalog", and share the same domain). And if I change _x to __ (and remove the context parameter) it picks that one as well. But as it is written, the "Add New" string simply wont show in PoEdit.
Even if I add manually the string to the po file, it will put it in the "obsolete strings" after trying to update to .po file from sources...
Would have thought that the "_x:1,2c;" bit would be enough to pick up the string, but it never does.
Is there something I'm doing wrong, or have I encountered an actual bug?
See the documentation for _x() at http://codex.wordpress.org/Function_Reference/_x — the second argument is context, which is a string included in the PO together with the source text to disambiguate otherwise identical strings with different meaning. The codex page above has an example; another one is e.g. "Open" that could be used in different context, so the programmer would use e.g. "File menu" as the context.
The important part is that it is handled the same way as the text to be translated. The text has to be a string literal for xgettext to extract it and so does the context (it has to be: it's something that goes into the PO file!).
$this->post_type is not a literal, which is why xgettext doesn't recognize it. There's no way it could know what the post_type value could be at runtime and so it couldn't possibly know what to write into the created PO file.
To fix this, you need to use _x() with at least the first two arguments string literals.
Related
I don't know if this is a bug or something wrong i am doing but when ever i type something and press enter to select from the auto complete menu it leaves whatever is written before... or specifically the # symbol for now
here a picture demonstration
enter image description here
enter image description here
So more to the question, Atom does replace whatever you type if you chose to auto-complete in contrary to what Brent said below. In an html file try typing dv or btn and select to auto-complete you'll then see that it replaces what you've typed. So this behavior is only (as far as i am concerned) replicable with symbols
From the Autocomplete section of the Atom Flight manual:
By default, the autocomplete system will look through the current open file for strings that match what you're starting to type.
If you've typed in part of a keyword that Atom doesn't recognize, and then autocomplete the rest of the phrase, Atom will not erase what you've previously typed. I used to do this a bunch when I first started using Atom. The solution is simple: just type the part of the keyword that Atom recognizes before auto-completing the rest of it. So in the case of your first example image, you just have to start typing the phrase media and then press enter; no need to include the preceding # symbol. This ultimately means that you just have to type less to get your desired code, which I think is pretty sweet.
I made a RML report, which is working perfect. In the translation files, the strings which are in the RML file are included, so I can translate the content of the report. But there's one case in which strings aren't recognized, therefore these can't be translated. I'm going to put an example:
Next line is working, "Category" is recognized by the translation files and I can translate it there.
<para style="terp_tblheader_General_Centre">Category</para>
Next one isn't working:
<para>[[ o.type == 'r' and 'Registration' or 'Deregistration' ]]</para>
That is the unique case in which strings are not being recognized. type is a selection field (which can take the values 'r' or 'd'), and I wrote that line to see in the report Registration (in case of type valueing 'r') or Deregistration (in case of type valueing 'd'). But Registration and Deregistration are not being recognized as words to be translated.
I saw this post:
Translation of strings in python code in RML reports
And I tried to write _('Registration') / _('Deregistration') and then _(Registration) / _(Deregistration) instead of 'Registration' / 'Deregistration', but in this case the string don't even appear in the report.
Anyone can help me, please?
For translation you must have to insert text in .po file. You check out under i18n folder for core modules like sale, purchase, account.
Load the translation under this path Setting => Translations => Load a Translation
Now assign language to the partner.
Add text value in .po file
Based on partner language it will change the text label like here is sample code of .rml file
<story>
<para style="terp_default_8">[[repeatIn(objects,'o')]]</para>
<para style="terp_default_8">[[ setLang(o.partner_id.lang) ]]</para>
Hope this will help you.
I'm aware that there are some languages that writes the order of some characters differently than the common latin languages. E.g.: a percentage number in English would be like "100%", while in Persian it would be "/100" (the symbol comes before the number).
Question: how to consider that in the Qt internationalization system in an intelligent way?
I first thought about this code:
myLabel->setText(tr("%1%2").arg(value).arg(tr("%")));
So what would happen is that, in the Qt Linguist, the translator would change the order of the replacement fields:
%1%2 -> in Persian translation -> %2%1
I checked that in my code and I found out that while in the normal (English) translation everything was fine, when I changed to the file containing the performed translation, a bug would occur: the number to be shown was never complete having one less number that what I had written. So e.g. if I chose "99%", it would show "%9", and if I set only "9%", I would have just "%".
The problem disappeared when I put a space between %1 and %2 both in the source code as well as in the translation (%2 %1). Since ISO xxxxx says that the % should be placed with a space between it and the correspondent number, no problem for this specific situation. But what If I wanted to have both symbols without a space between each other? How should it be done?
I confirm that the problem you described exists. However I would solve this problem in the following way:
QString sPer = QString("%%1").arg(value); // %99
QString sEng = QString("%1%").arg(value); // 99%
So that
%1% -> in Persian translation -> %%1
Put the percentage inside the string to translate, something like
myLabel->setText(tr("%%1").arg(value))
even better, I think I would add a disambiguation string (Qt "old style" comment)
myLabel->setText(tr("%%1", "Show the number with a percentage").arg(value))
or maybe a new style translation comment like this
//: Show the number with a percentage
myLabel->setText(tr("%%1").arg(value))
Translator comments have issues of their own, you might be better off using a Qt disambiguation string like the preceding example.
Putting a disambiguation string (or a translator comment) will let your translator know what they are translating...
Let the translators decide where they want to put the percentage, don't try to handle it in the code as somebody else suggested, it is not scalable, you can't start handling this in the code like that, what if you need to use another character or formatting for another language?
It might even be possible that Qt might have calls to handle number formatting but I can't seem to find them at the moment and I am not fully sure how we handle them in the Qt application I work on...
If putting a % alone doesn't work, try to precede it with \, it might be necessary to escape it, I am not sure...
I installed the String Overrides module and I have two entries in Site Configuration, one for Arabic and the other for English. I had put "Create Advertisement" inside of "Original field (English)" and some Arabic text inside "Replacement field." Nothing happened; no replacement was done.
I know there is something about wrapping the text in the t() function, but I do not know where to do it from. It is easy to do that in the case of replacing a field name but not here in this case. Can I have some help from you? I am using Drupal 6.19.
As reported in the project page, String Overrides can be used to replace anything that is passed through t(); if the English string is not used from any modules, you will not see the Arabic string being used.
If you are using "Create Advertisement" in your module, then the module should contain a call to t("Create Advertisement"). t() is case sensitive; if you are overriding "Create Advertisement," but the string used is "Create advertisement," then the string it will not be shown in Arabic.
I also think Arabic must be the language set for the page being shown.
I've never messed with AppleScript so this is only a concept to me. Can this work?
Bungie, the game designer, is hosting a ton of PNGs for Halo Reach in systematically named files and directories. IE:
http://www.bungie.net/images/reachstats/commendations/onyx/onyx_large_precision_multiplayer.png
Change two instances of the same word, and you generate another version of the image. Change "onyx" to "iron", "bronze", "silver" or "gold" and you get a corresponding image, like so:
http://www.bungie.net/images/reachstats/commendations/gold/gold_large_precision_multiplayer.png
Would an AppleScript be able to take an input URL, find and change the instances of the words in the URL, and then download the associated file to a directory? Today is my birthday (Oct 27th! hence the XXVII) and if this will work I would be super excited if someone could make this!
Thanks for all of your kind answers!
This works:
set the destination_file to ((path to desktop as string) & "picture.jpg") as file specification
set thisImageSRC to "http://www.bungie.net/images/reachstats/commendations/gold/gold_large_precision_multiplayer.png"
tell application "URL Access Scripting"
download thisImageSRC to destination_file replacing yes
end tell
String manipulation is done completely with changing Applescript's text item delimiters. So to get the components of the URL into a list, you need to do the following:
set oldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to "/"
set theUrlComponents to (every text item of theURL) as list
set AppleScript's text item delimiters to oldDelims
Add salt to taste, but I agree with the first commenter that there are better languages to do this. Applescript would be my last choice here.