I18n #60

Merged
elegaanz merged 23 commits from i18n into master 6 years ago
elegaanz commented 6 years ago (Migrated from github.com)

Here is the workflow I came with:

  • When we want to add a new locale, just list it in po/LINGUAS
  • When we want to translate something:
    • Use the _ or _n filters in the Tera template
    • Add the corresponding string to po/plume.pot
  • Then when you run cargo build (or cargo run), it:
    • Updates your translation files (.po ones) with new strings, or create them from the POT if they don't exist
    • Compile them to .mo files
  • On the Rocket side:
    • When launching, tell gettext where our .mo files are
    • For each request, fetch the requested locale from the Accept-Language header, and tell gettext to use it (with a dirty hack)

TODO:

  • Make the interface actually translatable (by replacing untranslatable strings with calls to _ and _n)
  • Write an internationalization guide
  • Compile translation when launching instead of at compile-time, to avoid useless builds (and make it easier to integrate with other projects in the future)
  • Put the i18n module in its own crate?

Fixes #58

Here is the workflow I came with: - When we want to add a new locale, just list it in `po/LINGUAS` - When we want to translate something: - Use the `_` or `_n` filters in the Tera template - Add the corresponding string to `po/plume.pot` - Then when you run `cargo build` (or `cargo run`), it: - Updates your translation files (`.po` ones) with new strings, or create them from the POT if they don't exist - Compile them to `.mo` files - On the Rocket side: - When launching, tell gettext where our `.mo` files are - For each request, fetch the requested locale from the `Accept-Language` header, and tell gettext to use it (with a dirty hack) TODO: - [x] Make the interface actually translatable (by replacing untranslatable strings with calls to `_` and `_n`) - [x] Write an internationalization guide - [x] Compile translation when launching instead of at compile-time, to avoid useless builds (and make it easier to integrate with other projects in the future) - [x] Put the `i18n` module in its own crate? Fixes #58
elegaanz commented 6 years ago (Migrated from github.com)

I made a crate for this, so that other Rocket-based projects can re-use it: https://crates.io/crates/rocket_i18n

I made a crate for this, so that other Rocket-based projects can re-use it: https://crates.io/crates/rocket_i18n
elegaanz commented 6 years ago (Migrated from github.com)

OK, I can't use the crate because we need to depend on Rocket master and crates.io won't let us do that.

Edit: actually, I can may use the git repository as a source

OK, I can't use the crate because we need to depend on Rocket `master` and crates.io won't let us do that. Edit: actually, I can may use the git repository as a source
trinity-1686a reviewed 6 years ago
@ -6,9 +6,9 @@
{% endblock title %}
Owner

I think a | _ is missing here

I think a `| _` is missing here
Owner

In-code strings like 5ae9cb3490/src/routes/blogs.rs (L59) are missing.
Adding translation by modifying only utils::requires_login, not each route files, seems to be the way

In-code strings like https://github.com/Plume-org/Plume/blob/5ae9cb3490a40b3e48b53b56d212035bc26695cc/src/routes/blogs.rs#L59 are missing. Adding translation by modifying only utils::requires_login, not each route files, seems to be the way
The pull request has been merged as cf676592aa.
You can also view command line instructions.

Step 1:

From your project repository, check out a new branch and test the changes.
git checkout -b i18n master
git pull origin i18n

Step 2:

Merge the changes and update on Forgejo.
git checkout master
git merge --no-ff i18n
git push origin master
Sign in to join this conversation.
No reviewers
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: Plume/Plume#60
Loading…
There is no content yet.