Coder Social home page Coder Social logo

Comments (24)

 avatar commented on May 9, 2024 1

Would it make sense to integrate this i18n https://github.com/TechMagister/i18n.cr , it seems to be what kemalyst uses.

from amber.

akzhan avatar akzhan commented on May 9, 2024 1

Just started https://github.com/akzhan/crystal-cldr (L10n foundation).

from amber.

drujensen avatar drujensen commented on May 9, 2024 1

we might be able to copy/leverage this middleware from Kemalyst

from amber.

imdrasil avatar imdrasil commented on May 9, 2024 1

@elorest please take a look on https://github.com/TechMagister/i18n.cr - now, I guess, it satisfies basic requirements for internationalization

from amber.

eliasjpr avatar eliasjpr commented on May 9, 2024 1

Do you want to keep i18n as a shard (like it's done now), or I should prepare a PR to be directly merged into Amber?

I am fine with a separate shard for i18n, let me know if you don't have repo create access I will create a repo for you. Also we have the naming convention of prefixing shards with a crystal name in front so like {Type Crystal}::i18n (You can pick the crystal since you have authored the i18n.

Is it OK if in config/application.cr after the Amber::Server.configure block one needs to add Amber::I18n.configure block, or this should be merged into the main server's configure block?

I would like to this to have its own initializer file just like granite. This will keep it consistent with the other shards.

Should the folder with locales be directly "./locales" on the top-level of an application, or something else?

Rails applications have a /config/locales I almost feel that this can live under the src/locales @amberframework/core-team please weight in.

Is it OK that current locale is read from ::I18n.locale? That's how the kemalyst-i18n does it, but I would think it would be better that this value (at least for the programmer) resides in Amber.locale, or context.locale, or similar?

This feels more of a context concern that Amber it self. I do not foresee people using locale outside of the context. I can be wrong.

5.1) How would you prefer translate and localize methods to be called, do we keep the names "translate" and "localize"?

I like the names I don't have any other suggestions.

Do we keep calling translate/localize under the I18n namespace or we add these methods under Amber module? (Like Amber.translate and Amber.localize)

I vote i18n namespace. Again I don't think this is an Amber concern. We can create an i18n module that people can include where they need the methods

5.3) Do we create "t" and "l" shorthands out of the box, or we leave that as minor local customization for app developers if/when they want it?

Yes 👍

from amber.

docelic avatar docelic commented on May 9, 2024 1

Hey @eliasjpr, regarding your comment "I am fine with a separate shard for i18n, let me know if you don't have repo create access I will create a repo for you."

Yes, please create it and I will submit PRs to it then. Thanks!

from amber.

docelic avatar docelic commented on May 9, 2024 1

Great, thanks, the shard code is in there now, and what remains is to integrate this into Amber as per above guidelines. I'll submit that PR to amber as soon as I manage.

from amber.

eliasjpr avatar eliasjpr commented on May 9, 2024

@usbsnowcrash feel free to propose an implementation of i18n

from amber.

akzhan avatar akzhan commented on May 9, 2024

I prefer node/babelfish and it should be easy to convert it to crystal.

Demo.

So I18n may be pluggable.

from amber.

marksiemers avatar marksiemers commented on May 9, 2024

@amberframework/core-team - We'll need to revisit this to decide what, if any work needs to be done in amber itself. Also, see what I18n solutions exist in the crystal eco-system now.

from amber.

eliasjpr avatar eliasjpr commented on May 9, 2024

We either need to provide some integration guide or a basic setup for this

from amber.

docelic avatar docelic commented on May 9, 2024

After looking into the comments above and all combinations of searches for existing Crystal shards, looks like the choices are (in no particular order).

https://github.com/akzhan/crystal-cldr
https://github.com/olbat/icu.cr
https://github.com/TechMagister/i18n.cr (and related https://github.com/TechMagister/kemalyst-i18n)

from amber.

imdrasil avatar imdrasil commented on May 9, 2024

I would suggest @TechMagister shard, but it has 2 major issues:

  • it doesn't support multiple localization files for one language (working on PR for this)
  • it doesn't support named interpolation inside of translation - just %s etc. (almost done this as well)

from amber.

docelic avatar docelic commented on May 9, 2024

@imdrasil are you in contact with the shard author? I haven't been able to reach him lately.

from amber.

imdrasil avatar imdrasil commented on May 9, 2024

@docelic no. I've thought he would be available but as I can see - I'm wrong 😞

from amber.

imdrasil avatar imdrasil commented on May 9, 2024

I've created a fork of his repo - if he doesn't response I will continue support my fork of his repo

from amber.

 avatar commented on May 9, 2024

I didn't received any notification from github, sorry 😕
I'll take a look at your work right away.

from amber.

docelic avatar docelic commented on May 9, 2024

@TechMagister I tried to reach you via Gitter and I also sent you an email, receiving no response. See my Liquid PRs.

from amber.

faustinoaq avatar faustinoaq commented on May 9, 2024

Can we support translation using .po files and gettext ?

So we could use translation editors like https://poedit.net/, WDYT?

from amber.

imdrasil avatar imdrasil commented on May 9, 2024

@faustinoaq it looks like interesting thing but I'm not pretty sure if this is reasonable and useful for current state. Also in the ruby world it is not widely spread

from amber.

docelic avatar docelic commented on May 9, 2024

Hey @eliasjpr @imdrasil @elorest, I made progress on this one using @TechMagister's i18n shard.
I've repurposed his kemalyst-i18n shard (which was much simpler than I thought) and now for Amber this works roughly in the following way:

  1. One adds "amber_i18n" shard to shards.yml
  2. In config/application.cr one adds an "Amber::I18n.configure" block if defaults need to be changed
  3. In config/routes.cr one adds Amber::Pipe::I18n which discovers the language from Accept-Language header and sets ::I18n.locale value

I've got a couple related questions about the overall functionality:

  1. Do you want to keep i18n as a shard (like it's done now), or I should prepare a PR to be directly merged into Amber?
  2. Is it OK if in config/application.cr after the Amber::Server.configure block one needs to add Amber::I18n.configure block, or this should be merged into the main server's configure block?
  3. Should the folder with locales be directly "./locales" on the top-level of an application, or something else?
  4. Is it OK that current locale is read from ::I18n.locale? That's how the kemalyst-i18n does it, but I would think it would be better that this value (at least for the programmer) resides in Amber.locale, or context.locale, or similar?
    1. How would you prefer translate and localize methods to be called, do we keep the names "translate" and "localize"?
    1. Do we keep calling translate/localize under the I18n namespace or we add these methods under Amber module? (Like Amber.translate and Amber.localize)
    1. Do we create "t" and "l" shorthands out of the box, or we leave that as minor local customization for app developers if/when they want it?

from amber.

imdrasil avatar imdrasil commented on May 9, 2024

yeah, @eliasjpr has just overtaken me - totally agree with him

from amber.

eliasjpr avatar eliasjpr commented on May 9, 2024

@docelic see https://github.com/amberframework/citrine-i18n

from amber.

docelic avatar docelic commented on May 9, 2024

Solved with #652

from amber.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.