@arc-js/intl 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,18 @@
1
+
2
+ import React from "react"
3
+ import { useEffect } from 'react';
4
+ import { useArcIntl } from '../providers/IntlProvider';
5
+ export const useTranslation = moduleName => {
6
+ const arcIntl = useArcIntl();
7
+ useEffect(() => {
8
+ if (moduleName) {
9
+ arcIntl.loadModuleTranslations(moduleName);
10
+ }
11
+ }, [moduleName]);
12
+ return {
13
+ t: arcIntl.t,
14
+ changeLocale: arcIntl.changeLocale,
15
+ currentLocale: arcIntl.currentLocale,
16
+ isLoading: arcIntl.isLoading
17
+ };
18
+ };
@@ -0,0 +1,20 @@
1
+ // arcIntl/hooks/useTranslation.ts
2
+ import { useEffect } from 'react';
3
+ import { useArcIntl } from '../providers/IntlProvider';
4
+
5
+ export const useTranslation = (moduleName?: string) => {
6
+ const arcIntl = useArcIntl();
7
+
8
+ useEffect(() => {
9
+ if (moduleName) {
10
+ arcIntl.loadModuleTranslations(moduleName);
11
+ }
12
+ }, [moduleName]);
13
+
14
+ return {
15
+ t: arcIntl.t,
16
+ changeLocale: arcIntl.changeLocale,
17
+ currentLocale: arcIntl.currentLocale,
18
+ isLoading: arcIntl.isLoading,
19
+ };
20
+ };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.0.4",
6
+ "version": "0.0.5",
7
7
  "description": "INTL est un système de gestion d'internationalisation (i18n) modulaire et performant pour les applications React avec TypeScript/JavaScript. Il fournit une gestion avancée des traductions, un chargement dynamique des modules, et une intégration transparente avec l'écosystème Arc.",
8
8
  "main": "index.js",
9
9
  "keywords": [],
@@ -1,11 +0,0 @@
1
- declare const SUPPORTED_LOCALES: string[];
2
- type Locale = typeof SUPPORTED_LOCALES[number];
3
-
4
- declare const useTranslation: (moduleName?: string) => {
5
- t: any;
6
- changeLocale: (locale: Locale) => Promise<void>;
7
- currentLocale: string;
8
- isLoading: boolean;
9
- };
10
-
11
- export { useTranslation };