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

remix-i18next

Package Overview
Dependencies
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remix-i18next - npm Package Compare versions

Comparing version 6.0.1 to 6.1.0

17

build/server.d.ts

@@ -109,1 +109,18 @@ import type { Cookie, EntryContext, SessionStorage } from "@remix-run/server-runtime";

}
/**
* The LanguageDetector contains the logic to detect the user preferred language
* fully server-side by using a SessionStorage, Cookie, URLSearchParams, or
* Headers.
*/
export declare class LanguageDetector {
private options;
constructor(options: LanguageDetectorOption);
private isSessionOnly;
private isCookieOnly;
detect(request: Request): Promise<string>;
private fromSearchParams;
private fromCookie;
private fromSessionStorage;
private fromHeader;
private fromSupported;
}

19

build/server.js

@@ -91,3 +91,8 @@ import { pick } from "accept-language-parser";

}
class LanguageDetector {
/**
* The LanguageDetector contains the logic to detect the user preferred language
* fully server-side by using a SessionStorage, Cookie, URLSearchParams, or
* Headers.
*/
export class LanguageDetector {
options;

@@ -123,3 +128,3 @@ constructor(options) {

if (method === "searchParams") {
locale = await this.fromSearchParams(request);
locale = this.fromSearchParams(request);
}

@@ -133,3 +138,3 @@ if (method === "cookie") {

if (method === "header") {
locale = await this.fromHeader(request);
locale = this.fromHeader(request);
}

@@ -141,3 +146,3 @@ if (locale)

}
async fromSearchParams(request) {
fromSearchParams(request) {
let url = new URL(request.url);

@@ -153,4 +158,4 @@ if (!url.searchParams.has(this.options.searchParamKey ?? "lng")) {

let cookie = this.options.cookie;
let lng = (await cookie.parse(request.headers.get("Cookie"))) ?? "";
if (!lng)
let lng = await cookie.parse(request.headers.get("Cookie"));
if (typeof lng !== "string" || !lng)
return null;

@@ -168,3 +173,3 @@ return this.fromSupported(lng);

}
async fromHeader(request) {
fromHeader(request) {
let locales = getClientLocales(request);

@@ -171,0 +176,0 @@ if (!locales)

{
"name": "remix-i18next",
"version": "6.0.1",
"version": "6.1.0",
"description": "The easiest way to translate your Remix apps",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -14,2 +14,5 @@ # remix-i18next

> [!TIP]
> If you're using Remix with Vite, check https://github.com/sergiodxa/remix-vite-i18next for an example application, if you have an issue compare your setup with the example.
### Installation

@@ -289,13 +292,2 @@

> **Warning** In latest versions you may find an error with `useChangeLanguage` hook, (see [#107](https://github.com/sergiodxa/remix-i18next/issues/107)), to solve it, you can deep import it from the package with `import { useChangeLanguage } from 'node_modules/remix-i18next/browser/react';`, or copy the code of `useChangeLanguage` to your own app and use it instead of the one provided by `remix-i18next`.
```ts
export function useChangeLanguage(locale: string) {
let { i18n } = useTranslation();
useEffect(() => {
i18n.changeLanguage(locale);
}, [locale, i18n]);
}
```
Finally, in any route you want to translate, you can use the `t()` function, as per the [i18next documentation](https://www.i18next.com/overview/api#t) and use translations from the default namespace.

@@ -302,0 +294,0 @@

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