Skip to content

Commit

Permalink
fix: Fix plural translations by importing missing locale-data
Browse files Browse the repository at this point in the history
Previously, I did not understand why plural translations did not work on iOS. They were returning the key instead of the pluralized translation. I duplicated the translations to support the JSON v3 fallback but it still did not work properly. They were always returning the singular key.

Here, I found that the root of the issue was the missing locale-data import needed by 'intl' and 'intl-pluralrules' polyfill.

So plural translations works and I removed the duplicate translations.
  • Loading branch information
zatteo committed Mar 19, 2024
1 parent e5ddf71 commit 83d0eb2
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 12 deletions.
4 changes: 0 additions & 4 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,11 @@
"onProgressTitle": "Uploading",
"onProgressMessage": "{{filename}} is being uploaded",
"backupSuccessTitle": "Photo & video backup",
"backupSuccessBody": "Your backup is complete! {{backedUpMediaCount}}/{{count}} saved item.",
"backupSuccessBody_one": "Your backup is complete! {{backedUpMediaCount}}/{{count}} saved item.",
"backupSuccessBody_other": "Your backup is complete! {{backedUpMediaCount}}/{{count}} saved items.",
"backupSuccessBody_plural": "Your backup is complete! {{backedUpMediaCount}}/{{count}} saved items.",
"backupPartialSuccessTitle": "Photo & video backup",
"backupPartialSuccessBody": "Your backup is stopped! {{backedUpMediaCount}}/{{count}} saved item.",
"backupPartialSuccessBody_one": "Your backup is stopped! {{backedUpMediaCount}}/{{count}} saved item.",
"backupPartialSuccessBody_other": "Your backup is stopped! {{backedUpMediaCount}}/{{count}} saved items.",
"backupPartialSuccessBody_plural": "Your backup is stopped! {{backedUpMediaCount}}/{{count}} saved items.",
"backupErrorTitle": "Oops",
"backupErrorBody": "Your backup encountered an error. Open the app to see more details."
},
Expand Down
4 changes: 0 additions & 4 deletions src/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,11 @@
"onProgressTitle": "Subiendo",
"onProgressMessage": "{{filename}} se está subiendo",
"backupSuccessTitle": "Copia de seguridad de fotos y vídeos",
"backupSuccessBody": "¡Tu copia de seguridad ha finalizado! {{backedUpMediaCount}}/{{count}} elemento guardado.",
"backupSuccessBody_one": "¡Tu copia de seguridad ha finalizado! {{backedUpMediaCount}}/{{count}} elemento guardado.",
"backupSuccessBody_other": "¡Tu copia de seguridad ha finalizado! {{backedUpMediaCount}}/{{count}} elementos guardados.",
"backupSuccessBody_plural": "¡Tu copia de seguridad ha finalizado! {{backedUpMediaCount}}/{{count}} elementos guardados.",
"backupPartialSuccessTitle": "Copia de seguridad de fotos y vídeos",
"backupPartialSuccessBody": "La copia de seguridad se ha detenido. {{backedUpMediaCount}}/{{count}} elemento guardado.",
"backupPartialSuccessBody_one": "La copia de seguridad se ha detenido. {{backedUpMediaCount}}/{{count}} elemento guardado.",
"backupPartialSuccessBody_other": "La copia de seguridad se ha detenido. {{backedUpMediaCount}}/{{count}} elementos guardados.",
"backupPartialSuccessBody_plural": "La copia de seguridad se ha detenido. {{backedUpMediaCount}}/{{count}} elementos guardados.",
"backupErrorTitle": "Oops",
"backupErrorBody": "Tu copia de seguridad ha encontrado un error. Abre la aplicación para ver más detalles."
},
Expand Down
4 changes: 0 additions & 4 deletions src/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,11 @@
"onProgressTitle": "Envoi en cours",
"onProgressMessage": "{{filename}} est en cours de sauvegarde",
"backupSuccessTitle": "Sauvegarde photo & vidéo",
"backupSuccessBody": "Votre sauvegarde est terminée ! {{backedUpMediaCount}}/{{count}} élément sauvegardé.",
"backupSuccessBody_one": "Votre sauvegarde est terminée ! {{backedUpMediaCount}}/{{count}} élément sauvegardé.",
"backupSuccessBody_plural": "Votre sauvegarde est terminée ! {{backedUpMediaCount}}/{{count}} éléments sauvegardés.",
"backupSuccessBody_other": "Votre sauvegarde est terminée ! {{backedUpMediaCount}}/{{count}} éléments sauvegardés.",
"backupPartialSuccessTitle": "Sauvegarde photo & vidéo",
"backupPartialSuccessBody": "Votre sauvegarde est arrêtée ! {{backedUpMediaCount}}/{{count}} élément sauvegardé.",
"backupPartialSuccessBody_one": "Votre sauvegarde est arrêtée ! {{backedUpMediaCount}}/{{count}} élément sauvegardé.",
"backupPartialSuccessBody_other": "Votre sauvegarde est arrêtée ! {{backedUpMediaCount}}/{{count}} éléments sauvegardés.",
"backupPartialSuccessBody_plural": "Votre sauvegarde est arrêtée ! {{backedUpMediaCount}}/{{count}} éléments sauvegardés.",
"backupErrorTitle": "Oops",
"backupErrorBody": "Votre sauvegarde a rencontré une erreur. Ouvrez l'app pour obtenir plus de détails."
},
Expand Down
3 changes: 3 additions & 0 deletions src/locales/i18n.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import _i18n, { Resource } from 'i18next'
import intervalPlural from 'i18next-intervalplural-postprocessor'
import 'intl'
import 'intl/locale-data/jsonp/en.js'
import 'intl/locale-data/jsonp/es.js'
import 'intl/locale-data/jsonp/fr.js'
import 'intl-pluralrules'
import { initReactI18next, useTranslation } from 'react-i18next'
import { getLocales } from 'react-native-localize'
Expand Down

0 comments on commit 83d0eb2

Please sign in to comment.