Closed jonnius closed 9 years ago
see Pull Request https://github.com/nls1729/acme-code/pull/2
First I want to thank you for your efforts. I have looked at your changes. They look good. I will merge your changes this weekend.
_N("TEXT") is a work around for using defined constants in js code. In May of 2012 I submitted an extension which had code like the following:
const _ = Gettext.gettext; . const DEFAULT_TEXT = "Activities"; . Main.panel._activitiesButton._label.settext((DEFAULT_TEXT));
The reviewer rejected my extension because the translation would not work.
From the the review: "2) _(DEFAULT_TEXT) alone won't work, because it won't be picked by intltool. You need to use _N("Activities") when you set DEFAULT_TEXT (where _N = function(x) { return x; })"
_(DEFAULT_TEXT) is actually Gettext.gettext(DEFAULT_TEXT). From the reviewer's response the constant DEFAULT_TEXT is/was not recognized as a string. This may be a bug that has been fixed since 2012.
const DEFAULT_TEXT = _N("Activities") is actually Gettext.gettext(function("Activities") { return "Activities"; })
The workaround is assigning a function and a parameter to the constant which is executed to return the string.
The Gnome flavor of javascript uses GObject introspection to utilize a large base of code written in C. Sometimes the interfacing is not smooth.
Again thanks.
Norman
I have done testing and found the following: const DEFAULTTEXT = ("Activities"); does no translation. The constant is set to the untranslated string but it does allow the translation tools to identify select the string for inclusion in a pot file as you have stated.
Main.panel._activitiesButton._label.settext((DEFAULT_TEXT)); Translation is performed on the string assigned to the constant.
I can find no reference for using const N = function(x) { return x; } related to translation; In my previous comment I did not clearly state what is happening. (DEFAULT_TEXT) is not Gettext.gettext(DEFAULT_TEXT) when assigning to a constant. const DEFAULT_TEXT = _N("Activities") is function("Activities") { return "Activities"; } assigned to the constant. My testing indicates the _N is/was not needed. A bug may have been fixed in gjs?
I have your branch in my local repo. I will do some testing and then merge later today.
I am not an expert. But from my experience
Main.panel._activitiesButton._label.set_text(_(DEFAULT_TEXT))
works fine. The only problem is, that by creating the translation template automatically it won't know the String to be translated, even thought it is a Constant. Thats why defining the constant as
const DEFAULT_TEXT = _("Activities");
would help. Actually by the moment when the constant is beeing defined
initTranslations()
has not been called, yet. So the real translation will happen when setting the label text. But this way to define the constant helps the xgettext find the translatable String.
I am not a professional programmer. This is only what I understood so far. And anyway it is working that way (i have tested it on my machine).
Regards, jonius
Edit: Didn't see your last message before answering...
Main.panel.activitiesButton._label.set_text((DEFAULT_TEXT)); Translation is performed on the string assigned to the constant.
should have been
Main.panel.activitiesButton._label.settext((DEFAULT_TEXT)); Translation is performed on the string assigned to the constant.
I found a couple of lines that need changing: extension.js 321 should be: Notify.notifyError(_(MIA_ICON),Readme.makeTextStr(Readme.ICONMIA)); extension.js 554 should be: Notify.notifyError((CONFLICT),Readme.makeTextStr(Readme.CONFLICTS));
I will also make changes to README.txt before I upload to the extension website.
I will merge your changes locally. Make the above changes locally and then push to github.
I will comment here when I have it all done.
I found a couple of lines that need changing: extension.js 321 should be: Notify.notifyError( _(MIA_ICON),Readme.makeTextStr(Readme.ICONMIA)); extension.js 554 should be: Notify.notifyError( (CONFLICT),Readme.makeTextStr(Readme.CONFLICTS));
I don't know what is happening but I had earlier copied and pasted the lines and they had the _ in the original.
I need to proof read more closely.
Sorry about that.
Norman
Whoa! When you preview the _ is missing unless it has a 2 preceding spaces.
To quote Elmer Fudd:
"There is something screwy going on around here."
Your pull request has been merged. The updated extension has been uploaded to ego for review.
I re-opened this issue to ask a favor. I am updating the extension to include a few things for GS 3.14 and 3.16. Updates are to optionally hide the icon displayed in the left of the panel for the current application with focus; to allow dragging through the hot corner to the overview when the hot corner is disabled; and hopefully to make the extension touch screen friendly.
Your help with a translation would be appreciated.
I ask you to verify (or do a better translation of) the following:
Hide Application Menu Button Icon
google translated to: Anwendungs ausblenden Menu Button Icon
Thanks, Norman
You cannot trust Google Translator about German. German is too complicated for Google to master. Correct translation: Schaltflächensymbol des Anwendungsmenüs verstecken
Usally the translation template file (*.pot) can be created automatically using the following command: xgettext -k -kN -o nls1729-extensions.pot prefs.js readme.js notify.js It finds all occurances of Strings of the kind _("TEXT"). It seems that you have changed the source code in a way that this does not work anymore for most of the Strings. Instead you use _N("TEXT") that seems to do nothing. Is there a reason why?