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

Switch momentjs internationalisation according to I18n locale #1819

Merged
merged 3 commits into from Nov 28, 2017
Merged

Switch momentjs internationalisation according to I18n locale #1819

merged 3 commits into from Nov 28, 2017

Conversation

leandroalemao
Copy link
Contributor

What? Why?

Hi
This PR is linked to the #1107
The issue is about momentjs internationalisation.
Always glad to help.
I hope all good.
Tks.
Leandro.

What should we test?

MomentJs stuff translated according to I18n locale.

Release notes

For now, I've just added internationalisation files for Spanish and French. If the PR is ok I can add for the other languages.

Dependencies

#1107

Copy link
Contributor

@sauloperez sauloperez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Impressive @leandroalemao I wouldn't expect this to be the issue.

moment.lang('es');
break;
case "fr":
moment.lang('fr');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't we do moment.lang(I18n.locale);? AFAIK we both (moment and OFN) use the standard acronym for languages. As it is, it would require adding a bunch of case statements more. I can think of Portugal at least cc @mllocs.


//= require moment
//= require moment/es.js
//= require moment/fr.js
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't require_tree do the trick? If I'm not mistaken (I'm not very familiar with the Rails asset pipeline), it'd require all the files in moment/

@leandroalemao
Copy link
Contributor Author

Hi @sauloperez how are you?
Do you know if this PR is gonna be merged? Is there any other issue I can help with? 👍 😄
Looking forward to hear from you
Tks
Leandro

@enricostano
Copy link
Contributor

Hi @leandroalemao many thanks for your precious time! I was just wondering if there is any way to avoid copy/pasting all that external code into OFN project and add it as a kind of dependency. What do you think? I'm not sure our package.json would be ready for that though.

cc/ @oeoeaio @mkllnk

@mkllnk
Copy link
Member

mkllnk commented Sep 15, 2017

Our current package.json is just to install the dependencies for the karma tests. Shouldn't the assets come with the momentjs-rails gem? They are listed in the repository: https://github.com/derekprior/momentjs-rails/tree/v2.5.1/vendor/assets/javascripts/moment

I'm worried that //= require moment/. will bloat up the all.js file. Maybe we can use config.i18n.available_locales?

@sauloperez
Copy link
Contributor

sauloperez commented Sep 19, 2017

Yep, if there's momentjs-rails gem that is the way. Sorry @leandroalemao, I was on vacations for some days ⛰️

@mkllnk
Copy link
Member

mkllnk commented Sep 20, 2017

Yes, there is and we are using it already.

gem 'momentjs-rails'

@daniellemoorhead
Copy link
Contributor

Where are we at with this, gentlemen? It's marked as critical so would be good to get it done. Does it need further changes/code review/testing? Do you need anything from the AU team to get it through?

@myriamboure
Copy link
Contributor

@leandroalemao @sauloperez do you have time to finish that in the coming days ? Yes it's kind of critical as frontend... Would be awesome if we could finish this off :-p

@leandroalemao
Copy link
Contributor Author

Hi @ALL what do I need to include more in this PR? We're already using momentjs-rails gem and I just added a small javascript code to actually switch momentjs locate globally.. just following the doc http://momentjs.com/docs/#/i18n/. The other files are jus the localisation files (fr.js es.js.. etc..) .. which latest versions of, weren't working.. so I put a previous version of them. I guess because the momentjs version is not the latest as well. I hope all good. Tks. Leandro

@sauloperez
Copy link
Contributor

What I don't quite understand @leandroalemao is if we use the gem, aren't these localisation files included in it already? Do we need to upgrade its version? if so, let's do it.

@daniellemoorhead daniellemoorhead modified the milestones: September dot point release, October dot point release Oct 5, 2017
@sauloperez
Copy link
Contributor

@leandroalemao do you need any help with this?

@leandroalemao
Copy link
Contributor Author

Hi @sauloperez Till yesterday I was working on the PR #1836. I'll have a look at this today. Tks. Leandro.

@sauloperez
Copy link
Contributor

Awesome @leandroalemao no pressure! I just thought we all forgot about this (myself included).

@daniellemoorhead daniellemoorhead removed this from the October dot point release milestone Oct 18, 2017
@sauloperez
Copy link
Contributor

sauloperez commented Nov 6, 2017

I take this over.

According to https://github.com/derekprior/momentjs-rails in order to include a localization file //= require moment/<locale>.js needs to be added. No need to add extra localization files.

captura de pantalla 2017-11-06 a les 21 24 43

@mllocs
Copy link
Collaborator

mllocs commented Nov 6, 2017

Could you diff the size of the js bundle where this is added? 🐘

@sauloperez
Copy link
Contributor

We go from 3.0MB to 3.1MB. That's already quite a lot.

@sauloperez
Copy link
Contributor

sauloperez commented Nov 9, 2017

Watch out, I had to rebase to get the tests fixed ⚠️

@daniellemoorhead
Copy link
Contributor

@oeoeaio can you have a look at this one as a priority please. It's marked as critical.

@myriamboure
Copy link
Contributor

Yes @daniellemoorhead @oeoeaio I know I said I won't ask another issue to be reviewed in priority but when testing v1.10 I realized this was still not fixed, this is a front end untranslated thing on every French shopfront, so pretty annoying for our users... would be great if we can prioritize as well.

@oeoeaio oeoeaio merged commit e98d934 into openfoodfoundation:master Nov 28, 2017
@mkllnk mkllnk requested a deployment to staging November 29, 2017 00:01 Abandoned
@oeoeaio oeoeaio added this to the Current release milestone Nov 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants