-
Notifications
You must be signed in to change notification settings - Fork 64
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
Add Swahili #544
Conversation
@@ -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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// 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 |
There was a problem hiding this comment.
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.
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'); | ||
}); |
There was a problem hiding this comment.
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.
77c943f
to
7b79423
Compare
The Swahili translations have been reviewed, and I've updated the last commit. Swahili should be ready to go out with v1.4! |
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 tosrc/util/i18n.js
as part of that and instead decided to move the existing flatpickr logic in that file intoDateRangePicker
. 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 tosrc/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.)