Comments (24)
Would it make sense to integrate this i18n https://github.com/TechMagister/i18n.cr , it seems to be what kemalyst uses.
from amber.
Just started https://github.com/akzhan/crystal-cldr (L10n foundation).
from amber.
we might be able to copy/leverage this middleware from Kemalyst
from amber.
@elorest please take a look on https://github.com/TechMagister/i18n.cr - now, I guess, it satisfies basic requirements for internationalization
from amber.
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.
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.
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.
@usbsnowcrash feel free to propose an implementation of i18n
from amber.
I prefer node/babelfish and it should be easy to convert it to crystal.
Demo.
So I18n may be pluggable.
from amber.
@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.
We either need to provide some integration guide or a basic setup for this
from amber.
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.
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.
@imdrasil are you in contact with the shard author? I haven't been able to reach him lately.
from amber.
@docelic no. I've thought he would be available but as I can see - I'm wrong 😞
from amber.
I've created a fork of his repo - if he doesn't response I will continue support my fork of his repo
from amber.
I didn't received any notification from github, sorry 😕
I'll take a look at your work right away.
from amber.
@TechMagister I tried to reach you via Gitter and I also sent you an email, receiving no response. See my Liquid PRs.
from amber.
Can we support translation using .po
files and gettext ?
So we could use translation editors like https://poedit.net/, WDYT?
from amber.
@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.
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:
- One adds "amber_i18n" shard to shards.yml
- In config/application.cr one adds an "Amber::I18n.configure" block if defaults need to be changed
- 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:
- 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?
- 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?
- Should the folder with locales be directly "./locales" on the top-level of an application, or something else?
- 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?
-
- How would you prefer translate and localize methods to be called, do we keep the names "translate" and "localize"?
-
- Do we keep calling translate/localize under the I18n namespace or we add these methods under Amber module? (Like Amber.translate and Amber.localize)
-
- 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.
yeah, @eliasjpr has just overtaken me - totally agree with him
from amber.
@docelic see https://github.com/amberframework/citrine-i18n
from amber.
Solved with #652
from amber.
Related Issues (20)
- Website funding is over and needs to be renegotiated every year with digital ocean. HOT 3
- Change from Github Actions -> CircleCI
- Improve Installation Documentation & Experience for Windows/Linux Users HOT 4
- `amber g ` creates system tests that are incomplete for controller/request testing
- `resources` macro _should_ accept a block for nesting unRESTful routes HOT 2
- Improve the Auth generated by `amber g auth` HOT 2
- Feature: Unify the API for config vars HOT 1
- Enhancement: Improving the generators for greater flexibility
- Enhancement: Automatically return 400 response if param validation fails HOT 1
- amber 1.3.2 regression test failure against crystal 1.9.1 HOT 5
- amber 1.4.0 test failure HOT 4
- Requests with `content-type` `application/json` do not parse params correctly
- Automatically generated mock data files
- Create Installation instructions for brew on linux
- Use Ansible to test installation instructions for different OSes HOT 2
- Sqlite dependency version missmatch HOT 1
- Inexistent docker image in generated Dockerfile HOT 2
- First registered connection cannot be nil HOT 2
- Automatically Create and Migrate Test Databases on Linux
- Discord server HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from amber.