Skip to content
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

i18n Support #17

Open
Chew opened this issue Dec 20, 2020 · 2 comments · May be fixed by #22
Open

i18n Support #17

Chew opened this issue Dec 20, 2020 · 2 comments · May be fixed by #22
Labels
backend This issue or pull request relates to an issue/change on the backend logistics Something that requires something out of our control (Geyser admins for example)

Comments

@Chew
Copy link
Member

Chew commented Dec 20, 2020

Rails has native i18n support (see config/locales).

In the code, you need to do the following:

t('key')

Or, in controllers:

I18n.t('key')

Assuming you have the corresponding value in config/locales/en.yml:

key: Global Value

You can specify the locale however we want. Maybe a dropdown for it in the navbar?

If there are no translations in the given language, it falls back to the default (English).

I've not much experience with Crowdin, but it should be pretty simple to figure out. I won't be the one able to make it, though.

On RubyMine, not sure about other clients, but selecting a t('string') and pressing CMD+0 hides it with the actual translation. Quite poggers

For strings specific to a file/controller, you simply need to do this:

In locale:

controller:
  action:
    key: Local Value

So in app/controllers/controller.rb method action or app/views/controller/action.html.erb you can do:

t('.key')

Which will put "Local Value" instead of "Global Value". It definitely saves on key length.

There are not many Strings right now, but we don't want to get too far behind.

@Chew Chew added backend This issue or pull request relates to an issue/change on the backend logistics Something that requires something out of our control (Geyser admins for example) labels Dec 20, 2020
@Chew Chew pinned this issue Dec 20, 2020
@rtm516
Copy link
Member

rtm516 commented Dec 30, 2020

You can specify the locale however we want. Maybe a dropdown for it in the navbar?

I think we should get this from the users IP (geo IP lookup) and allow the user to set it when logged in? Navbar would be good for non-logged-in users.

Im happy to add a branch to the https://github.com/GeyserMC/languages repo but I think we need things pulling into an en.yml first, then I can setup the submodule and crowdin config.

@Chew
Copy link
Member Author

Chew commented Dec 30, 2020

Sounds good. The locale is in config/locales but is unoccupied as we haven't been doing it as we've been going.

@Chew Chew linked a pull request Jan 4, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend This issue or pull request relates to an issue/change on the backend logistics Something that requires something out of our control (Geyser admins for example)
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

2 participants