Closed cghove closed 1 year ago
I will look into this and come back with more information. More particularly I will investigate if we can use Crowdin, which is used for translating Project-GC, to translate this as well. And how cumbersome that workflow will be.
The Userscript starts of by calling the API method GetMyUsername to get some initial data. I have added locale
to that data blob as well. In the future maybe the API method should be renamed since it's now returning a bunch of data beside the username. The patch to add locale
isn't live yet, only in our development environment. But it can be expected to be added soon.
When added it can be used as an override for the web browsers language for example.
When looking into adding files to Crowdin I happened to notice that the pgc.en.json starts with the section heder
, I assume it should say header
(typo).
I have come as far as that I have added the pgc.en.json
to Crowdin for translation. It's a manual step. Then when I am fetching translations for Project-GC the Userscript translations ends up as https://project-gc.com/locale/nb_NO/userscript.json
(only dev yet, not in production).
The translators are fast at Crowdin and there are a few languages where most is translated already (I imported your nb_NO translations).
I am not sure which approach will be best here though. Shall we build two scripts? One for pushing pgc.en.json to Crowdin, and another to fetch translations into the Git-repository?
PS! The merge is fine to me, maybe fix that heder
vs header
. Then I didn't really review the code, I just trust it. So in my opinion we could merge this and then split out the process discussion in another Issue?
By the way, is it some best practice to have both these? Or would it be smarter to just have one in this case? They are not likely to change into different wordings?
"gallery": "Project-GC Gallery",
"gallery2": "Project-GC Gallery",
One of the Swedish translators usually notices things, and it didn't take him many minutes to find this, and question it.
By the way, is it some best practice to have both these? Or would it be smarter to just have one in this case? They are not likely to change into different wordings?
"gallery": "Project-GC Gallery", "gallery2": "Project-GC Gallery",
One of the Swedish translators usually notices things, and it didn't take him many minutes to find this, and question it.
"gallery": "Project-GC Gallery"
"Gallery 2": "PGC Gallery"
they are supposed to be different
"gallery": "Project-GC Gallery" "Gallery 2": "PGC Gallery"
they are supposed to be different
Aha, I see now. I just saw the Swedish translation and therefore didn't realize they were different. Because of lack of pixel-space I guess.
EDIT: Or now I am just confused. Because the EN-file has the same translation on them. Was it a mistake to have the same string on them?
"gallery": "Project-GC Gallery" "Gallery 2": "PGC Gallery"
they are supposed to be different
Aha, I see now. I just saw the Swedish translation and therefore didn't realize they were different. Because of lack of pixel-space I guess.
EDIT: Or now I am just confused. Because the EN-file has the same translation on them. Was it a mistake to have the same string on them?
They are the same in the EN-file due to me not proofreading enough... 🙈 But in the script they are different...
I will look into this and come back with more information. More particularly I will investigate if we can use Crowdin, which is used for translating Project-GC, to translate this as well. And how cumbersome that workflow will be.
The Userscript starts of by calling the API method GetMyUsername to get some initial data. I have added
locale
to that data blob as well. In the future maybe the API method should be renamed since it's now returning a bunch of data beside the username. The patch to addlocale
isn't live yet, only in our development environment. But it can be expected to be added soon.When added it can be used as an override for the web browsers language for example.
That would also mean that something like this need to be added to the script:
//declare the language variable as empty, in the beginning of the script
var _language = "";
function CheckPGCLogin() {
GM.xmlHttpRequest({
method: "GET",
url: pgcApiUrl + 'GetMyUsername',
onload: function(response) {
var result = JSON.parse(response.responseText);
_**language = response.locale; //untested code
i18next.changeLanguage(_language);//untested code**
if (result.status !== 'OK') {
alert(response.responseText);
return false;
}
pgcUsername = result.data.username;
// Issue 113 & #133; fixed 2022-09-04 (Units of elevation obtained from Project-GC)
imperialFlag = result.data.imperialUnits;
loggedIn = Boolean(result.data.loggedIn);
subscription = Boolean(result.data.subscription);
When looking into adding files to Crowdin I happened to notice that the pgc.en.json starts with the section
heder
, I assume it should sayheader
(typo).
Yes a typo, but it's an invisible typo 😜 , so if that one word is changed, we also need to change all : i18next.t("heder...
strings, since it's a reference variable
Not sure if it's needed but in the cachetur assistant we've added all languages we have in the translation tool to whitelist: ['nb_NO', 'en'], preload: ['nb_NO', 'en'],
And I guess it's obvious, but the loadpath
loadPath: 'https://raw.githubusercontent.com/magma1447/greasemonkey-geocaching-projectgc/master/language/{{ns}}.{{lng}}.json',
crossDomain: true
need to be changed to where you end up storing the translations
Hmm... for some reason
when i change the loadpath to match the language files on PGC
loadpath: 'https://project-gc.com/locale/{{lng}}/{{ns}}.json',
The script tries to load the translations from https://www.geocaching.com/locales/nb_NO/userscript.json and not https://project-gc.com//locales/nb_NO/userscript.json
Actually got it to try to load the translations from the pgcurl. But got a cors error, not sure if that's something @magma1447 has to switch on server side?
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://project-gc.com/locale/en_US/userscript.json. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). Status code: 200.
This is what I found now. I'll see if I can fix it myself in this Pull request.
Not sure if @magma1447 have considered this option before, but here's the framwork for a multilanguage script. Think I've gotten all text strings into the json files. But not sure if the translations should be done and kept here on github, or if @magma1447 maybe only want the initial pgc.en.json here to add new strings and then pull that file into whatever tool is beeing used to translate the website, and call the strings from there. The script will detect the language of the browser, and should default to English if the users language don't exist