Skip to content

Commit

Permalink
BREAKING: Removing i18next-icu (#799)
Browse files Browse the repository at this point in the history
* (chore) Removing i18next-icu as it is supported for i18next v19

* (chore) Added interpolation overrides for prefix and suffix to not break the whole application

* Reverting changes in package.json

* Updated translation files with new interpolation rules

* Using i18next's default configuration
  • Loading branch information
vasharma05 authored Oct 27, 2023
1 parent 0543b67 commit fd113a4
Show file tree
Hide file tree
Showing 12 changed files with 41 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,11 @@ const OfflineActionsTable: React.FC<OfflineActionsTableProps> = ({
disabled={disableEditing || disableDelete}
onClick={() => onDelete(selectedRows.map((row) => +row.id))}
>
{selectedRows.length === 1
? t("offlineActionsTableDeleteAction", "Delete action")
: t(
"offlineActionsTableDeleteActions",
"Delete {count} actions",
{ count: selectedRows.length }
)}
{t(
"offlineActionsTableDeleteActions",
"Delete {{count}} actions",
{ count: selectedRows.length }
)}
</Button>
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { Trans } from "react-i18next";
import { useTranslation } from "react-i18next";
import { Layer, Tile } from "@carbon/react";
import { useLayoutType } from "@openmrs/esm-framework";
import { EmptyDataIllustration } from "./empty-data-illustration.component";
Expand All @@ -14,6 +14,7 @@ const EmptyState: React.FC<EmptyStateProps> = ({
displayText,
headerTitle,
}) => {
const { t } = useTranslation();
const isTablet = useLayoutType() === "tablet";
return (
<Layer>
Expand All @@ -25,9 +26,9 @@ const EmptyState: React.FC<EmptyStateProps> = ({
</div>
<EmptyDataIllustration />
<p className={styles.content}>
<Trans i18nKey="emptyStateText" values={{ displayText: displayText }}>
There are no {displayText} to display
</Trans>
{t("emptyStateText", "There are no {{displayText}} to display", {
displayText,
})}
</p>
</Tile>
</Layer>
Expand Down
7 changes: 3 additions & 4 deletions packages/apps/esm-offline-tools-app/translations/am.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"emptyStateText": "There are no {displayText} to display",
"emptyStateText": "There are no {{displayText}} to display",
"home": "Home",
"homeHeader": "Offline home",
"homeOverviewCardOfflineActionsFailedToUpload": "Failed to upload",
Expand All @@ -20,9 +20,8 @@
"offlineActionsNoActionsEmptyStateTitle": "No actions pending upload",
"offlineActionsTableAction": "Action",
"offlineActionsTableCreatedOn": "Date & Time",
"offlineActionsTableDeleteAction": "Delete action",
"offlineActionsTableDeleteActions_one": "Delete {count} actions",
"offlineActionsTableDeleteActions_other": "Delete {count} actions",
"offlineActionsTableDeleteActions_one": "Delete action",
"offlineActionsTableDeleteActions_other": "Delete {{count}} actions",
"offlineActionsTableError": "Error",
"offlineActionsTablePatient": "Patient",
"offlineActionsUpdateOfflinePatients": "Update offline patients",
Expand Down
15 changes: 7 additions & 8 deletions packages/apps/esm-offline-tools-app/translations/ar.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"emptyStateText": "لا يوجد {displayText} لعرضه",
"emptyStateText": "لا يوجد {{displayText}} لعرضه",
"home": "الرئيسية",
"homeHeader": "الصفحة الرئيسية بدون اتصال",
"homeOverviewCardOfflineActionsFailedToUpload": "فشل في التحميل",
Expand All @@ -20,13 +20,12 @@
"offlineActionsNoActionsEmptyStateTitle": "لا توجد أنشطة في انتظار التحميل",
"offlineActionsTableAction": "الإجراء",
"offlineActionsTableCreatedOn": "التاريخ والوقت",
"offlineActionsTableDeleteAction": "حذف الإجراء",
"offlineActionsTableDeleteActions_zero": "حذف {count} إجراءات",
"offlineActionsTableDeleteActions_one": "حذف {count} إجراء",
"offlineActionsTableDeleteActions_two": "حذف {count} إجراءات",
"offlineActionsTableDeleteActions_few": "حذف {count} إجراءات",
"offlineActionsTableDeleteActions_many": "حذف {count} إجراءات",
"offlineActionsTableDeleteActions_other": "حذف {count} إجراءات",
"offlineActionsTableDeleteActions_zero": "حذف {{count}} إجراءات",
"offlineActionsTableDeleteActions_one": "حذف الإجراء",
"offlineActionsTableDeleteActions_two": "حذف {{count}} إجراءات",
"offlineActionsTableDeleteActions_few": "حذف {{count}} إجراءات",
"offlineActionsTableDeleteActions_many": "حذف {{count}} إجراءات",
"offlineActionsTableDeleteActions_other": "حذف {{count}} إجراءات",
"offlineActionsTableError": "خطأ",
"offlineActionsTablePatient": "المريض",
"offlineActionsUpdateOfflinePatients": "تحديث المرضى بدون اتصال",
Expand Down
11 changes: 4 additions & 7 deletions packages/apps/esm-offline-tools-app/translations/en.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"actions": "Actions",
"emptyStateText": "There are no {displayText} to display",
"emptyStateText": "There are no {{displayText}} to display",
"home": "Home",
"homeHeader": "Offline home",
"homeOverviewCardOfflineActionsFailedToUpload": "Failed to upload",
Expand All @@ -21,9 +20,8 @@
"offlineActionsNoActionsEmptyStateTitle": "No actions pending upload",
"offlineActionsTableAction": "Action",
"offlineActionsTableCreatedOn": "Date & Time",
"offlineActionsTableDeleteAction": "Delete action",
"offlineActionsTableDeleteActions_one": "Delete {count} actions",
"offlineActionsTableDeleteActions_other": "Delete {count} actions",
"offlineActionsTableDeleteActions_one": "Delete action",
"offlineActionsTableDeleteActions_other": "Delete {{count}} actions",
"offlineActionsTableError": "Error",
"offlineActionsTablePatient": "Patient",
"offlineActionsUpdateOfflinePatients": "Update offline patients",
Expand Down Expand Up @@ -55,6 +53,5 @@
"offlinePatientSyncDetailsFallbackErrorMessage": "Unknown error.",
"offlinePatientSyncDetailsHeader": "Offline patient details",
"offlineReady": "Offline Ready",
"offlineToolsAppMenuLink": "Offline tools",
"patients": "Patients"
"offlineToolsAppMenuLink": "Offline tools"
}
13 changes: 5 additions & 8 deletions packages/apps/esm-offline-tools-app/translations/es.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"actions": "Acciones",
"emptyStateText": "No hay {displayText} para mostrar",
"emptyStateText": "No hay {{displayText}} para mostrar",
"home": "Inicio",
"homeHeader": "Inicio offline",
"homeOverviewCardOfflineActionsFailedToUpload": "Error al cargar",
Expand All @@ -21,10 +20,9 @@
"offlineActionsNoActionsEmptyStateTitle": "No hay acciones pendientes de carga",
"offlineActionsTableAction": "Acción",
"offlineActionsTableCreatedOn": "Fecha y Hora",
"offlineActionsTableDeleteAction": "Eliminar acción",
"offlineActionsTableDeleteActions_one": "Eliminar {count} acciones",
"offlineActionsTableDeleteActions_many": "Eliminar {count} acciones",
"offlineActionsTableDeleteActions_other": "Eliminar {count} acciones",
"offlineActionsTableDeleteActions_one": "Eliminar acción",
"offlineActionsTableDeleteActions_many": "Eliminar {{count}} acciones",
"offlineActionsTableDeleteActions_other": "Eliminar {{count}} acciones",
"offlineActionsTableError": "Error",
"offlineActionsTablePatient": "Paciente",
"offlineActionsUpdateOfflinePatients": "Actualizar pacientes offline",
Expand Down Expand Up @@ -56,6 +54,5 @@
"offlinePatientSyncDetailsFallbackErrorMessage": "Error desconocido.",
"offlinePatientSyncDetailsHeader": "Detalles de pacientes offline",
"offlineReady": "Listo offline",
"offlineToolsAppMenuLink": "Herramientas offline",
"patients": "Pacientes"
"offlineToolsAppMenuLink": "Herramientas offline"
}
13 changes: 5 additions & 8 deletions packages/apps/esm-offline-tools-app/translations/fr.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"actions": "Actions",
"emptyStateText": "There are no {displayText} to display",
"emptyStateText": "There are no {{displayText}} to display",
"home": "Accueil",
"homeHeader": "Accueil hors ligne",
"homeOverviewCardOfflineActionsFailedToUpload": "Échec du téléchargement",
Expand All @@ -21,10 +20,9 @@
"offlineActionsNoActionsEmptyStateTitle": "Aucune actions en attente de téléchargement",
"offlineActionsTableAction": "Action",
"offlineActionsTableCreatedOn": "Date & Heure",
"offlineActionsTableDeleteAction": "Supprimer l'action",
"offlineActionsTableDeleteActions_one": "Supprimer les {count} actions ",
"offlineActionsTableDeleteActions_many": "Delete {count} actions",
"offlineActionsTableDeleteActions_other": "Supprimer les {count} actions ",
"offlineActionsTableDeleteActions_one": "Supprimer l'action",
"offlineActionsTableDeleteActions_many": "Supprimer les {{count}} actions",
"offlineActionsTableDeleteActions_other": "Supprimer les {{count}} actions",
"offlineActionsTableError": "Erreur",
"offlineActionsTablePatient": "Patient",
"offlineActionsUpdateOfflinePatients": "Mettre à jour les patients hors ligne",
Expand Down Expand Up @@ -56,6 +54,5 @@
"offlinePatientSyncDetailsFallbackErrorMessage": "Erreur inconnue.",
"offlinePatientSyncDetailsHeader": "Détails des patients hors ligne",
"offlineReady": "Prêt pour être hors ligne",
"offlineToolsAppMenuLink": "Outils hors ligne",
"patients": "Les patients"
"offlineToolsAppMenuLink": "Outils hors ligne"
}
11 changes: 5 additions & 6 deletions packages/apps/esm-offline-tools-app/translations/he.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"emptyStateText": "There are no {displayText} to display",
"emptyStateText": "There are no {{displayText}} to display",
"home": "דף הבית",
"homeHeader": "דף הבית במצב לא מקוון",
"homeOverviewCardOfflineActionsFailedToUpload": "העלאה נכשלה",
Expand All @@ -20,11 +20,10 @@
"offlineActionsNoActionsEmptyStateTitle": "אין פעולות ממתינות להעלאה",
"offlineActionsTableAction": "פעולה",
"offlineActionsTableCreatedOn": "תאריך ושעה",
"offlineActionsTableDeleteAction": "מחק פעולה",
"offlineActionsTableDeleteActions_one": "מחק {count} פעולה",
"offlineActionsTableDeleteActions_two": "Delete {count} actions",
"offlineActionsTableDeleteActions_many": "Delete {count} actions",
"offlineActionsTableDeleteActions_other": "מחק {count} פעולות",
"offlineActionsTableDeleteActions_one": "מחק פעולה",
"offlineActionsTableDeleteActions_two": "מחק {{count}} פעולות",
"offlineActionsTableDeleteActions_many": "מחק {{count}} פעולות",
"offlineActionsTableDeleteActions_other": "מחק {{count}} פעולות",
"offlineActionsTableError": "שגיאה",
"offlineActionsTablePatient": "מטופל",
"offlineActionsUpdateOfflinePatients": "עדכן מטופלים לא מקוונים",
Expand Down
5 changes: 2 additions & 3 deletions packages/apps/esm-offline-tools-app/translations/km.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"emptyStateText": "There are no {displayText} to display",
"emptyStateText": "There are no {{displayText}} to display",
"home": "ផ្ទះ",
"homeHeader": "Offline home",
"homeOverviewCardOfflineActionsFailedToUpload": "Failed to upload",
Expand All @@ -20,8 +20,7 @@
"offlineActionsNoActionsEmptyStateTitle": "No actions pending upload",
"offlineActionsTableAction": "Action",
"offlineActionsTableCreatedOn": "Date & Time",
"offlineActionsTableDeleteAction": "Delete action",
"offlineActionsTableDeleteActions_other": "Delete {count} actions",
"offlineActionsTableDeleteActions_other": "Delete {{count}} actions",
"offlineActionsTableError": "Error",
"offlineActionsTablePatient": "Patient",
"offlineActionsUpdateOfflinePatients": "Update offline patients",
Expand Down
1 change: 0 additions & 1 deletion packages/shell/esm-app-shell/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
"html-webpack-plugin": "^5.5.0",
"i18next": "^21.10.0",
"i18next-browser-languagedetector": "^6.1.8",
"i18next-icu": "^2.3.0",
"import-map-overrides": "^3.0.0",
"lodash-es": "4.17.21",
"react": "^18.1.0",
Expand Down
2 changes: 0 additions & 2 deletions packages/shell/esm-app-shell/src/locale.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as i18next from "i18next";
import ICU from "i18next-icu";
import LanguageDetector from "i18next-browser-languagedetector";
import { initReactI18next } from "react-i18next";
import merge from "lodash-es/merge";
Expand Down Expand Up @@ -81,7 +80,6 @@ export function setupI18n() {
},
})
.use(initReactI18next)
.use(ICU)
.init({
detection: {
order: ["querystring", "htmlTag", "localStorage", "navigator"],
Expand Down
10 changes: 0 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3709,7 +3709,6 @@ __metadata:
html-webpack-plugin: ^5.5.0
i18next: ^21.10.0
i18next-browser-languagedetector: ^6.1.8
i18next-icu: ^2.3.0
import-map-overrides: ^3.0.0
lodash-es: 4.17.21
react: ^18.1.0
Expand Down Expand Up @@ -12061,15 +12060,6 @@ __metadata:
languageName: node
linkType: hard

"i18next-icu@npm:^2.3.0":
version: 2.3.0
resolution: "i18next-icu@npm:2.3.0"
peerDependencies:
intl-messageformat: ^10.3.3
checksum: da5cbf1fed795921dc903f8bd9129b5ad8ef4c5acd9cdea00c096a2dd4fafc8007cdc0501c11db5f86c7bfda8cde71896f8a4321129ead3557196a76fd4ad2d0
languageName: node
linkType: hard

"i18next-parser@npm:^6.6.0":
version: 6.6.0
resolution: "i18next-parser@npm:6.6.0"
Expand Down

0 comments on commit fd113a4

Please sign in to comment.