-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Translations feature added for documents
- Loading branch information
1 parent
d5eb4ae
commit 44b9338
Showing
22 changed files
with
258 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"invoice": "Invoice", | ||
"invoice-number": "Invoice number", | ||
"invoice-date": "Invoice date", | ||
"invoice-customer-details": "Details", | ||
"invoice-bill-to": "Bill to", | ||
"invoice-ship-to": "Ship to", | ||
"invoice-table-header-item": "Item", | ||
"invoice-table-header-description": "Description", | ||
"invoice-table-header-unit-cost": "Unit Cost", | ||
"invoice-table-header-quantity": "Quantity", | ||
"invoice-table-header-line-total": "Line Total", | ||
"invoice-table-shipping": "Shipping", | ||
"invoice-table-tax": "Tax", | ||
"invoice-table-total": "Total", | ||
"packing-slip": "Packing Slip", | ||
"packing-slip-bill-to": "Bill to", | ||
"packing-slip-ship-to": "Ship to", | ||
"packing-slip-table-header-order-number": "Order #", | ||
"packing-slip-table-header-order-date": "Order date", | ||
"packing-slip-table-header-shipping-method": "Shipping method", | ||
"packing-slip-table-header-item": "Item", | ||
"packing-slip-table-header-description": "Description", | ||
"packing-slip-table-header-quantity": "Quantity", | ||
"packing-slip-table-header-total": "Total" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"invoice": "Faktura", | ||
"invoice-number": "Numer faktury", | ||
"invoice-date": "Data faktury", | ||
"invoice-customer-details": "Dane klienta", | ||
"invoice-bill-to": "Nabywca", | ||
"invoice-ship-to": "Wysyłka do", | ||
"invoice-table-header-item": "Produkt", | ||
"invoice-table-header-description": "Opis", | ||
"invoice-table-header-unit-cost": "Cena jedn.", | ||
"invoice-table-header-quantity": "Ilość", | ||
"invoice-table-header-line-total": "Wartość", | ||
"invoice-table-shipping": "Wysyłka", | ||
"invoice-table-tax": "Podatek", | ||
"invoice-table-total": "Suma", | ||
"packing-slip": "List przewozowy", | ||
"packing-slip-bill-to": "Nabywca", | ||
"packing-slip-ship-to": "Wysyłka do", | ||
"packing-slip-table-header-order-number": "Zamówienie nr", | ||
"packing-slip-table-header-order-date": "Data zamówienia", | ||
"packing-slip-table-header-shipping-method": "Metoda wysyłki", | ||
"packing-slip-table-header-item": "Produkt", | ||
"packing-slip-table-header-description": "Opis", | ||
"packing-slip-table-header-quantity": "Ilość", | ||
"packing-slip-table-header-total": "Suma" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { | ||
ConfigModule, | ||
MedusaContainer, | ||
} from "@medusajs/medusa" | ||
|
||
import i18next from 'i18next'; | ||
import path from "path"; | ||
|
||
export default async ( | ||
container: MedusaContainer, | ||
config: ConfigModule | ||
): Promise<void> => { | ||
console.info("Starting i18next loader...") | ||
|
||
try { | ||
const defaultTranslationsPath = path.resolve(__dirname, `../assets/i18n/locales/en/translation.json`); | ||
const defaultTranslations = await import(defaultTranslationsPath); | ||
|
||
await i18next | ||
.init({ | ||
fallbackLng: 'en', | ||
defaultNS: 'translation', | ||
ns: 'translation', | ||
resources: { | ||
en: { | ||
translation: defaultTranslations | ||
} | ||
} | ||
}).catch((error) => { | ||
console.error(error); | ||
}); | ||
|
||
} catch (error) { | ||
console.error('Error initializing i18next:', error); | ||
} | ||
|
||
|
||
try { | ||
const configLanguage = config['documentLanguage']; | ||
if (configLanguage === undefined) { | ||
console.info('Language is not configured, using "en" by default.') | ||
} else { | ||
console.info(`Language is configured as ${configLanguage}`) | ||
const translationPath = path.resolve(__dirname, `../assets/i18n/locales/${configLanguage}/translation.json`); | ||
const translations = await import(translationPath); | ||
i18next.addResourceBundle( | ||
configLanguage, | ||
'translation', | ||
translations | ||
) | ||
i18next.changeLanguage(configLanguage); | ||
} | ||
} catch { | ||
console.error('Error adding language configured in config. Fallback to "en"'); | ||
} | ||
|
||
console.info("Ending i18next loader...") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.