ziko-providers 0.2.0 → 0.5.0

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.
package/README.md CHANGED
@@ -1,12 +1,20 @@
1
- > [!NOTE]
1
+ This is project is deprecated
2
+ replaced by [ziko-i18n](https://www.npmjs.com/package/ziko-i18n)
3
+
4
+
5
+
6
+ [![zikojs community](https://github.com/zikojs/.github/raw/main/assets/community.svg)](https://github.com/zikojs)
7
+
8
+
9
+ <!-- > [!NOTE]
2
10
  > This project is part of the [ZikoJS](https://github.com/zakarialaoui10/ziko.js) ecosystem.
3
11
 
4
12
 
5
13
  ## List of providers
6
14
 
7
- |Provider|Description|
8
- |`DirectionProvider`||
9
- |`ThemeProvider`||
15
+ - Direction : `DirectionProvider`
16
+ - I18N : `createI18NProvider`, `useTranslation`
17
+
10
18
 
11
19
  <!-- ## Install
12
20
 
@@ -20,5 +28,5 @@ If you appreciate the library, kindly demonstrate your support by giving it a st
20
28
 
21
29
  ## Financial support -->
22
30
 
23
- # Licence
24
- This projet is licensed under the terms of MIT License
31
+ <!-- # Licence
32
+ This projet is licensed under the terms of MIT License --> -->
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ziko-providers",
3
- "version": "0.2.0",
3
+ "version": "0.5.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -32,6 +32,12 @@
32
32
  "rollup": "^4.24.0"
33
33
  },
34
34
  "dependencies": {
35
- "ziko": "^0.62.0"
35
+ "mdzjs": "^0.11.3",
36
+ "zextra": "^0.13.0",
37
+ "ziko": "^0.62.0",
38
+ "ziko-server": "^0.18.1",
39
+ "ziko-tgl": "^0.7.5",
40
+ "ziko-wrapper": "^0.30.2",
41
+ "zikofy": "^0.7.2"
36
42
  }
37
43
  }
@@ -0,0 +1 @@
1
+ export * from './use-translate.js'
@@ -0,0 +1,31 @@
1
+ import { useState } from 'ziko/hooks';
2
+
3
+ export function useTranslation(
4
+ initialLang = __Ziko__?.__PROVIDERS__?.i18n?.lang,
5
+ locals = __Ziko__.__PROVIDERS__?.i18n?.locals
6
+ ) {
7
+ const [lang, _setLang] = useState(initialLang);
8
+
9
+ const setLang = (lang, rtl) =>{
10
+ document.documentElement.lang = lang;
11
+ document.documentElement.style.direction = rtl ? 'rtl' : 'ltr'
12
+ _setLang(lang)
13
+ }
14
+
15
+ setLang(initialLang)
16
+
17
+ function t(key) {
18
+ return () => ({
19
+ value : locals[lang().value][key],
20
+ isStateGetter: () => true,
21
+ _subscribe: (fn) => {
22
+ lang()._subscribe(
23
+ () => fn(locals[lang().value][key])
24
+ );
25
+ }
26
+ });
27
+ }
28
+
29
+ return [t, setLang];
30
+ }
31
+
package/src/i18n/index.js CHANGED
@@ -1,14 +1,2 @@
1
- import { Provider } from '../provider.js';
2
- class __I18NProvider__ extends Provider{
3
- constructor(component, {lang, locals}){
4
- super(component)
5
- document.documentElement.lang = lang;
6
- if(!globalThis.__Ziko__.__PROVIDERS__) globalThis.__Ziko__.__PROVIDERS__ = {}
7
- globalThis.__Ziko__.__PROVIDERS__.i18n = {
8
- lang,
9
- locals
10
- }
11
- }
12
- }
13
-
14
- export const I18NProvider = (component, {lang, locals}) => new __I18NProvider__(component, {lang, locals});
1
+ export * from './provider.js'
2
+ export * from './hooks/index.js'
@@ -0,0 +1,7 @@
1
+ export function createI18NProvider(lang, locals){
2
+ if(!globalThis.__Ziko__.__PROVIDERS__) globalThis.__Ziko__.__PROVIDERS__ = {}
3
+ globalThis.__Ziko__.__PROVIDERS__.i18n = {
4
+ lang,
5
+ locals,
6
+ }
7
+ }
package/src/provider.js CHANGED
@@ -1,4 +1,4 @@
1
- import { UIElement } from "ziko/src/ui/index.js";
1
+ import { UIElement } from "ziko/src/ui/constructors/UIElement.js"
2
2
 
3
3
  export class Provider extends UIElement{
4
4
  constructor(component){
Binary file