ssborbis / ContextSearch-web-ext

Search engine manager for modern browsers
321 stars 36 forks source link

About localized translation #584

Closed 7peanuts closed 1 year ago

7peanuts commented 1 year ago
ssborbis commented 1 year ago

I translated the help.thml file into Chinese, but it doesn't take effect. What other places need to be modified?

I'll take a look to see why that's not loading. The code should load whatever help.html is in the current locale dir.

I found that some information in the messages.json file was not found in the CS configuration options, will this affect translation?

Nah, any omissions or mistakes, etc will simply be replaced by words from the default messages.json, i.e. English. As long as the .json is well formed, you can't really go wrong.

The content of the current messages.json file is arranged in alphabetical order, and it is not very easy to find the corresponding position in the options, is there a better way?

I don't think so. I just check HTML through the source code, the Web Developer inspection tools, or the console for errors related to i18n messages and correct as I go. I suppose I could add some code to aid translators in the future; some way of showing the messages.json code that corresponds to each string the the options page.

ssborbis commented 1 year ago

Can you open up a console window from the CS Options page and enter this command

 browser.i18n.getUILanguage(); 

That should tell you what directory it's looking in for help.html

I wonder if this is the old zh-CN vs zh_CN issue. We'll see

7peanuts commented 1 year ago

That should tell you what directory it's looking in for help.html

I wonder if this is the old zh-CN vs zh_CN issue. We'll see

20221014100141

Got it, I put the help.html in the zh-CN folder and it shows up.

But in dark mode, the bold font will not be visible.

Also, the sample gifs seems to no longer exist, so maybe I'll make a few to put in there sometime. 20221014101306

ssborbis commented 1 year ago

Got it, I put the help.html in the zh-CN folder and it shows up.

Good deal

But in dark mode, the bold font will not be visible.

I'll update the dark css

Also, the sample gifs seems to no longer exist, so maybe I'll make a few to put in there sometime.

Shoot. You'll have to replace all instances of /native-app-support/ with /master/. Should be a quick find & replace. I just did the English version

I've added the hidden option developerMode. When enabled, if you click on a word or sentence in the options page, the keyword for that message in messages.json is copied to the clipboard and echoed in the console. That might help with translations in the future.

ssborbis commented 1 year ago

Some of those videos need to be updated too

7peanuts commented 1 year ago

You'll have to replace all instances of /native-app-support/ with /master/. Should be a quick find & replace.

I have replaced, now I can see the animation. So, how do I upload the translated help.html, create a new zh-CN folder?

ssborbis commented 1 year ago

So, how do I upload the translated help.html, create a new zh-CN folder?

Do you mean on my repo or yours? I tend to use software the integrates with github to manage my source code, so directories and files are put where they need to be with the click of a button. For a long time, I did most of my updates through the browser, which can be tedious. You can just post files here until you get comfortable working the web interface.

7peanuts commented 1 year ago

I tend to use software the integrates with github to manage my source code, so directories and files are put where they need to be with the click of a button.

If I create a new zh-CN folder, so that there will be two Chinese translation folders. Should I create pull requests in the development branch?

ssborbis commented 1 year ago

If I create a new zh-CN folder, so that there will be two Chinese translation folders.

I would like to figure out whether one will do. It seems odd we'd need both to get the translations working properly. I'll look around to see how other addons are managing this.

Should I create pull requests in the development branch?

Yes, please. I tend to reserve the master branch for releases.

ssborbis commented 1 year ago

Ok, it looks like all locale folders need to have underscores, not hyphens. I've consolidated your help.html and messages.json into the folder zh_CN and removed the other folder. I also added code to fix the help.html issue ( I think ) . Test it out when you get a chance. I'm prepping for a release soon.

7peanuts commented 1 year ago

Ok, it looks like all locale folders need to have underscores, not hyphens. I've consolidated your help.html and messages.json into the folder zh_CN and removed the other folder. I also added code to fix the help.html issue ( I think ) .

I downloaded the development branch folder and copied them to the 1.45.3_0 folder, but it didn't work.

ssborbis commented 1 year ago

Hmm... I'll see what I can do from here with changing locales, but I've found it problematic for testing. I won't release until this is sorted.

ssborbis commented 1 year ago

Ok, I see what's going on. I'll post here when I have something to test.

7peanuts commented 1 year ago

I've added the hidden option developerMode. When enabled, if you click on a word or sentence in the options page, the keyword for that message in messages.json is copied to the clipboard and echoed in the console. That might help with translations in the future.

I won't release until this is sorted.

I am looking forward to this feature, it will be very helpful to improve translation after release. Locales can be released later.

ssborbis commented 1 year ago

I am looking forward to this feature

It's in the dev branch now, if you're sideloading.

I also pushed what I hope is the fix for all these _locale issues. I've added a new message LOCALE_FOLDER to every messages.json file. This will tell the options page the exact folder to look for help.html in. There didn't seem to be a way to get the folder programmatically, so this is the easiest solution. Fingers crossed...

7peanuts commented 1 year ago

I also pushed what I hope is the fix for all these _locale issues. I've added a new message LOCALE_FOLDER to every messages.json file. This will tell the options page the exact folder to look for help.html in. There didn't seem to be a way to get the folder programmatically, so this is the easiest solution. Fingers crossed...

AHA, now I can see the translation of help.html.

In addition, I added some tips to the help.html. help.zip

ssborbis commented 1 year ago

Thanks.

Coincidentally, I'm having a back-and-forth with some Mozilla devs over files in _locale/xx/ folders. I can no longer submit a new release to Mozilla because this addon fails validation if any files other than messages.json appear in a locale folder as of a few weeks ago. I may need to relocate the help.html files in the future. Just a heads-up.

https://github.com/mozilla/addons-linter/issues/4540

ssborbis commented 1 year ago

mozilla fixed their issues. Your translations should be live in AMO and Chromestore shortly. Open a new issue if run into any problems

7peanuts commented 1 year ago

That's awesome, this 1.46 update is quite informative, I'll try it one by one.