New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@solid-primitives/i18n

Package Overview
Dependencies
Maintainers
3
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@solid-primitives/i18n - npm Package Compare versions

Comparing version 1.3.0 to 1.4.0

32

dist/index.d.ts
import * as solid_js from 'solid-js';
import { FlowComponent, Accessor, Setter } from 'solid-js';
type NestedKeyOf<T extends object> = {
[Key in keyof T & (string | number)]: T[Key] extends object ? `${Key}` | `${Key}.${NestedKeyOf<T[Key]>}` : `${Key}`;
}[keyof T & (string | number)];
type NestedValueOf<T extends object, K extends NestedKeyOf<T> | string> = K extends keyof T & (string | number) ? T[K] : K extends `${infer P extends keyof T & (string | number)}.${infer R}` ? T[P] extends object ? NestedValueOf<T[P], R> : unknown : unknown;
type Translate<T = unknown> = T extends object ? (key: NestedKeyOf<T>, params?: Record<string, string>, defaultValue?: string) => string : (key: string, params?: Record<string, string>, defaultValue?: string) => string;
type I18nAction = {
add(lang: string, table: Record<string, unknown>): void;
locale: (lang?: string) => string;
dict: (lang: string) => Record<string, Record<string, unknown>>;
};
type I18nContextInterface<T = unknown> = [Translate<T>, I18nAction];
type UseScopedI18n<T = unknown> = T extends object ? <K extends NestedKeyOf<T>>(scope: K) => I18nContextInterface<NestedValueOf<T, K>> : (<U extends object, K extends NestedKeyOf<U>>(scope: K) => I18nContextInterface<NestedValueOf<U, K>>) | ((scope: string) => I18nContextInterface);
/**

@@ -17,18 +30,5 @@ * This creates a I18nContext. It's extracted into a function to be able to type the Context

}];
type I18nContextInterface = ReturnType<typeof createI18nContext>;
declare const I18nContext: solid_js.Context<[template: (key: string, params?: Record<string, string>, defaultValue?: string) => any, actions: {
add(lang: string, table: Record<string, any>): void;
locale: (lang?: string) => string;
dict: (lang: string) => Record<string, Record<string, any>>;
}]>;
declare const useI18n: () => [template: (key: string, params?: Record<string, string>, defaultValue?: string) => any, actions: {
add(lang: string, table: Record<string, any>): void;
locale: (lang?: string) => string;
dict: (lang: string) => Record<string, Record<string, any>>;
}];
declare const useScopedI18n: (scope: string) => [template: (key: string, params?: Record<string, string>, defaultValue?: string) => any, actions: {
add(lang: string, table: Record<string, any>): void;
locale: (lang?: string) => string;
dict: (lang: string) => Record<string, Record<string, any>>;
}];
declare const I18nContext: solid_js.Context<I18nContextInterface>;
declare const useI18n: <T = unknown>() => I18nContextInterface<T>;
declare const useScopedI18n: UseScopedI18n;

@@ -35,0 +35,0 @@ type I18nFormatOptions = Record<string, string | number>;

@@ -71,4 +71,7 @@ import { createContext, createSignal, useContext, DEV } from 'solid-js';

var useScopedI18n = (scope) => {
const [translate, actions] = useContext(I18nContext);
return [(key, ...rest) => translate(`${scope}.${key}`, ...rest), actions];
const [translate, actions] = useI18n();
return [
(key, ...rest) => translate(`${scope}.${key}`, ...rest),
actions
];
};

@@ -75,0 +78,0 @@ function buildChainedDictionary(obj) {

{
"name": "@solid-primitives/i18n",
"version": "1.3.0",
"version": "1.4.0",
"description": "Primitive to create and use i18n primitives.",

@@ -56,4 +56,3 @@ "author": "Alexandre Mouton-Brady <amoutonbrady@gmail.com>",

"scripts": {
"dev": "vite serve dev",
"page": "vite build dev",
"dev": "jiti ../../scripts/dev.ts",
"build": "jiti ../../scripts/build.ts",

@@ -60,0 +59,0 @@ "test": "vitest -c ../../configs/vitest.config.ts",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc