Skip to content

Localization #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 32 commits into from
Closed

Localization #14

wants to merge 32 commits into from

Conversation

gervasiocaj
Copy link

@gervasiocaj gervasiocaj commented Apr 24, 2017

This feature allows localization to any language, with incomplete translation to pt. It uses the i18next framework, and modifies the questions.js and ideologies.js to extract the necessary strings and move them to the respective JSON files in the locales folder. The binding is still a bit ugly, for example:

<h2 id="results" class="translate"></h2>
<p id="results_desc" class="translate"></p>
for (i of document.getElementsByClassName("translate")) {
    document.getElementById(i.id).innerHTML=i18next.t(i.id)
}
{
    "results": "Résultats",
    "results_desc": "Lorem ipsum dolor sit amet."
}

Resolves #5

Progress of adaptation:
- [x] Questions
- [x] Quiz
- [ ] Index
- [ ] Instructions
- [ ] Results
    Progress of adaptation:
    - [x] Questions
    - [x] Quiz
    - [x] Index
    - [x] Instructions
    - [ ] Results
Progress of adaptation:
  - [x] Questions
  - [x] Quiz
  - [x] Index
  - [x] Instructions
  - [x] Results
@gervasiocaj gervasiocaj mentioned this pull request Apr 26, 2017
@Jameskmonger
Copy link

There seems to be a lot of code duplication between the different pages. Would it be possible to get this put into its own script?

In order to load the namespaces and do the string binding, just load the i18n.js file on the HTML and call the i18n_load_ns with the namespaces notation found [here](http://i18next.com/translate/namespace/).
To fill the string data (e.g. "12 apples), the element must adhere to the following notation (see HTML data-* attributes):

```html
<p data-i18n="apple_count" data-amount="18"></p>
```
```json
{ "apple_count": "{{amount}} apples" }
```

To refresh the string, alter the data-* attribute accordingly and call `i18n_ready()`.
@gervasiocaj
Copy link
Author

According to 6200b85:

In order to load the namespaces and do the string binding, just load the i18n.js file on the HTML and call the i18n_load_ns() with the namespaces notation found here.
To fill the string data (e.g. "12 apples"), the element must adhere to the following notation (see HTML data-* attributes):

<p data-i18n="apple_count" data-amount="18"></p>
{ "apple_count": "{{amount}} apples" }

To refresh the string, alter the data-* attribute accordingly and call i18n_ready().

@gervasiocaj gervasiocaj reopened this Apr 28, 2017
@TristanBomb
Copy link
Contributor

I'd like to thank you for all the work you've put into this! Unfortunately, I'm not really familiar with the framework you're using. Just a few things:

  • I changed a few things recently to improve the accuracy of the test. I hate to do this, but would you mind adapting the changes?
  • Is there any way to alter the .svg files for differing localizations?

Thanks!

@gervasiocaj gervasiocaj force-pushed the localization branch 2 times, most recently from 12aa91b to 6200b85 Compare May 4, 2017 18:07
@gervasiocaj
Copy link
Author

@TristanBomb how did you generate/drew the images?

gervasiocaj and others added 4 commits May 5, 2017 13:36
To localize images, add the file-[lng].svg to the value_images/ diretory and add an entry on the corresponding translation.json:

    "file.svg": "file-[lng].svg"
@elifoster
Copy link
Contributor

@TristanBomb The best way to handle internationalized images is to render the text using CSS instead of actually putting in the image. I took a look at some of the svg files that are in this project and it should be pretty simple.

@dalssoft
Copy link

any update? this seems to be a very important upgrade which would be make 8values available to a much broader audience. btw, congrats @TristanBomb, @gervasiocaj et al for the hard work!

@gervasiocaj
Copy link
Author

IMHO it is pretty stable, but the Portuguese translation is not finished yet. Waiting for @TristanBomb word on It.

@JoshuaKimsey
Copy link

I don't know! I absolutely agree that translations would be of a huge help to make 8Values even more wide spread! However, I too have had a pull request waiting for a while now too with no word from @TristanBomb. Hopefully, both @gervasiocaj and I will here soon.

P.S: Congrats to @gervasiocaj for the outstanding work he did to get the translations working! 😄

@dalssoft
Copy link

@gervasiocaj do you have a URL running for this PR on pt-br? this would be useful as is and wouldn't be necessary to wait for @TristanBomb decision

@gervasiocaj
Copy link
Author

@dalssoft
Copy link

it's still in en-US :(

@gervasiocaj
Copy link
Author

Try this https://gervasiocaj.github.io/8values.github.io/?lng=pt

@dalssoft
Copy link

@gervasiocaj what's the best way to translate the remaining text in en?

@gervasiocaj
Copy link
Author

gervasiocaj commented Jun 27, 2017

Submit a PR to my fork editing this file. These are the original strings.

@laurenzfg
Copy link

Hi @gervasiocaj how is the progress of your l18n efforts? If the technical stuff is done and you finalized the syntax of the .json files, I'd be more than happy to start working on a German translation.

@gervasiocaj
Copy link
Author

You can revise this German translation: https://github.com/gervasiocaj/8values.github.io/tree/localization/locales/de

@laurenzfg
Copy link

I will certainly look into it! Thank you for providing me with the relevant directory.

@sentfanwyaerda
Copy link

Hi, personally I dislike the javascript approach of making it i18n. I made a simple PHP PATCH: https://github.com/sentfanwyaerda/8waarden.nl (including the dutch 'nl' translation)

@JoshuaKimsey
Copy link

JoshuaKimsey commented Oct 10, 2017

@sentfanwyaerda While something like that might work better/ be more efficient than using just pure JavaScript, here's one issue I see. That would be the first introduction of PHP into this project, which would require making sure that PHP is setup properly on the hosting server. As it is right now, the user can run the html files locally on their computer and the program will function perfectly normal. Introducing PHP adds an extra amount of work needed to get an environment setup for users to use the code, either on a server or locally on their own computer.

Maybe @TristanBomb and the other contributors are ok with this, I honestly don't know! In all honesty, using PHP would probably be easier code wise. The issues arise from the users end with having to deal with PHP. Ultimately, I do believe that sticking with pure JS is a better solution for the user, even if it means more work on our end.

@gervasiocaj
Copy link
Author

At the moment we have complete translations to pt, es and de. Thanks everyone!

@JoshuaKimsey
Copy link

Hey, that's great @gervasiocaj! What other languages are you aiming to have the test be in at this point?

@renanpvaz
Copy link

Shouldn't this PR be merged already so other languages can be added later?

@gervasiocaj
Copy link
Author

I am about to merge the commit cd97fa1, which introduces some changes in the text. Looking for suggestions and solutions to track the progress of these translations, since they might be outdated for a while until the contributors have some free time.

@snorepion
Copy link

I've started working on an Esperanto translation. Are the only files that I need to change the JSON files in localization branch/locales/eo (copied from locales/en)?
Once I finish Esperanto, I'll start working on Swedish too.

@Genora51
Copy link
Member

I'm closing this PR and moving the conversation over to #123 to include the newest updates to 8values; it would be great to revive the thread over on that PR and get it merged soon!

@Genora51 Genora51 closed this Sep 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Translation