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

Add Swahili #544

Merged
merged 5 commits into from
Feb 23, 2022
Merged

Add Swahili #544

merged 5 commits into from
Feb 23, 2022

Conversation

matthew-white
Copy link
Member

@matthew-white matthew-white commented Feb 19, 2022

This PR adds Swahili to Frontend. This required a couple of changes in addition to the usual tasks.

First, there was an error parsing the Transifex JSON, because the translator used a \n. That shouldn't have been a problem, because we convert \n in Transifex strings to space. Actually, the Transifex JSON for Japanese also seems to contain strings with \n without issue. However, the presence of \n specifically within a pluralized string resulted in an error here. Luckily, a small change to a regular expression was all that was needed.

Second, Swahili is the first locale for us for which there isn't a flatpickr localization. I think we should consider submitting a PR to flatpickr for that, since I think it'd be pretty easy. However, for now, I modified DateRangePicker so that it works even if there isn't a flatpickr localization (it falls back to English). I didn't want to add more flatpickr-related logic to src/util/i18n.js as part of that and instead decided to move the existing flatpickr logic in that file into DateRangePicker. The result is more consistent with how we approach internationalization in other components. I had also already made that change as part of moving to Vue 3 (in #526). That PR makes a few changes to src/util/i18n.js, in large part because the i18n object will no longer be a global object. More about flatpickr localization: https://flatpickr.js.org/localization/

I may update the last commit as translations are updated, but I don't plan to make changes to the other commits. Because of that, I think we can go ahead and review this PR. An interactive review would probably be easiest, but I think async would also work. Because this PR touches the same file as the Vue 3 PR, it'd be good to merge it soon. (Swahili will hopefully be ready by the time we want to release, but even if we decide to release it in a patch, we'd be able to temporarily hide these translations.)

@matthew-white matthew-white requested a review from ktuite February 19, 2022 22:25
@@ -87,7 +87,7 @@ class PluralForms {
// Transifex uses ICU plurals.
static fromTransifex(string, locale) {
const forms = [];
const icuMatch = string.match(/^({count, plural,).+}$/);
const icuMatch = string.match(/^({count, plural,).+}$/s);
Copy link
Member Author

Choose a reason for hiding this comment

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

Comment on lines -83 to -86
// If this.$i18n.locale changes, this.config will change, but flatpickr
// itself won't change:
// https://github.com/flatpickr/flatpickr/issues/1882
// https://github.com/flatpickr/flatpickr/issues/2019
Copy link
Member Author

Choose a reason for hiding this comment

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

This seems to be working now! Because of that, I removed these comments.

Comment on lines 285 to 296
it('specifies a flatpickr locale if the i18n locale is es', () =>
loadLocale('es')
.then(() => {
const { locale } = mountComponent().vm.config;
locale.weekdays.longhand[0].should.equal('Domingo');
})
.finally(() => loadLocale('en')));
it('renders correctly for es', async () => {
await loadLocale('es');
const component = mountComponent({ attachTo: document.body });
await component.get('input').trigger('click');
const text = document.querySelector('.flatpickr-weekday').textContent.trim();
text.should.equal('Lun');
});
Copy link
Member Author

Choose a reason for hiding this comment

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

Instead of inspecting the config computed property, we actually cause the flatpickr element to be rendered, then inspect the element. That feels like a surer test that things are working and actually wasn't that much more complicated to write.

@matthew-white
Copy link
Member Author

The Swahili translations have been reviewed, and I've updated the last commit. Swahili should be ready to go out with v1.4!

@matthew-white matthew-white merged commit 00e457b into master Feb 23, 2022
@matthew-white matthew-white deleted the add-sw branch February 23, 2022 04:35
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.

2 participants