@solid-primitives/i18n
Advanced tools
Comparing version 0.0.105 to 0.0.250
@@ -35,3 +35,3 @@ /** | ||
dict: (lang: string) => Record<string, Record<string, any>>; | ||
}] | undefined>; | ||
}]>; | ||
export declare const useI18n: () => [template: (key: string, params?: Record<string, string> | undefined, defaultValue?: string | undefined) => any, actions: { | ||
@@ -41,3 +41,3 @@ add(lang: string, table: Record<string, any>): void; | ||
dict: (lang: string) => Record<string, Record<string, any>>; | ||
}] | undefined; | ||
}]; | ||
export {}; |
@@ -140,3 +140,3 @@ import { createSignal, createContext, useContext } from "solid-js"; | ||
}; | ||
export const I18nContext = createContext(); | ||
export const I18nContext = createContext({}); | ||
export const useI18n = () => useContext(I18nContext); |
{ | ||
"name": "@solid-primitives/i18n", | ||
"version": "0.0.105", | ||
"version": "0.0.250", | ||
"description": "Primitive to create and use i18n primitives.", | ||
@@ -5,0 +5,0 @@ "author": "Alexandre Mouton-Brady <amoutonbrady@gmail.com>", |
@@ -18,5 +18,5 @@ # @solid-primitives/i18n | ||
```tsx | ||
import { render } from "solid-js/dom"; | ||
import { render } from "solid-js/web"; | ||
import { Component, createSignal } from "solid-js"; | ||
import { I18nProvider, useI18n } from "@amoutonbrady/solid-i18n"; | ||
import { I18nProvider, createI18nContext, useI18n } from "@solid-primitives/solid-i18n"; | ||
@@ -57,8 +57,9 @@ const App: Component = () => { | ||
}; | ||
const value = createI18nContext(dict, "fr"); | ||
render( | ||
() => ( | ||
<I18nProvider dict={dict} locale="fr"> | ||
<I18nContext.Provider value={value}> | ||
<App /> | ||
</I18nProvider> | ||
</I18nContext.Provider> | ||
), | ||
@@ -65,0 +66,0 @@ document.getElementById("app") |
11164
82