Closed Anthony-Gaudino closed 8 years ago
This looks interesting but it defies the simplicity and flexibility of the plugin. For instance, what about users having a language called english
instead of en
or en-US
or en_US
. This is all not defined within the plugin.
This is what I would suggest instead: If the i18n-rails
gem is present, dynamically load the date and language translations into the plugin. This would make it very maintainable and gives the user options. By any chance, do you know how to retrieve the language data from i18n-rails
during runtime?
I have looked at the repository. This looks promising.
I have looked at it more extensively and the rails-i18n
package does not provide any language names. The only thing I can extract are date formats and day and month names.
I have just abstracted the data processing in the plugin and added a loader for rails-i18n
. Upgrade to version 1.2.0
and include rails-i18n
in your Gemfile
. You have all dates available.
Wow!
I tough would help you on this, but you just nailed it.
I was looking for an alternative for the languages names and found two gems that are specialized in this:
Language names and dates are now built-in.
Nice, I think that adding the languages on the plugin is great, and it's much more simple than having to load it from other gems.
Why didn't you said you wanted to add the language files? I could have helped you.
Can I add the other languages or are you already working on it?
I have written a script that imports the languages from the gems you have listed above. The script only imports languages where all data can be extracted from the gems. rails-i18n
only provides the language name in one language. i18n-iso639matrix
provides language name translations.
Which languages do you want to add? IMO that is enough for this plugin.
OK, so you used the script to generate all those 27 language files.
Since you are embedding the translations into the plugin it won't require the other gems, right?
Exactly. I have only chosen those few languages because I wanted the data to be as complete as possible for every language.
Btw, what other translations did you mean when you said other interesting strings? I have looked at relative time but IMO for a static site that does not make any sense.
I meant something that could be useful, for example, units or currency.
Unfortunately those gems don't have all strings translated, so some of them will come as English.
That's why I will leave the data as it is for now. If you want to, you can add more translations for your own site. You can even add your own loader (but it is not documented yet). Look at Jekyll::LanguagePlugin::Loaders::BuildinDataLoader
.
Ok, I will try to add as many languages I can and then I will open a pull request when I'm done.
Make sure that you add the additional language names to all existing languages then. Also, please restrict yourself to ISO369-1 two-letter language codes only.
OK.
Please make your changes in a new branch.
Sure.
How do you like it if I create YAML files containing translated dates, translated language names and maybe other things for most languages?
Rails-i18n provide files with translations for dates and other things.
You will be able to include the files on the plugin or make it available to users, so they can use on their websites.
It would be something like this:
So, if someone wants to create a menu with links for all available languages, they can query the
language
in the YAML and create a list like this:If you want to, you can even automate the plugin to look for the Jekyll
date
liquid tag and translate the date without the user having to use another liquid tag just for it, but then in this case, the user would need to use the same language names provided by the plugin.And if you think there's other interesting strings that could be added I will see what I can do.