-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
style: run prettier on the entire codebase
- Loading branch information
Showing
12 changed files
with
230 additions
and
206 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
{ | ||
"useTabs": false, | ||
"printWidth": 800, | ||
"tabWidth": 2, | ||
"singleQuote": true, | ||
"trailingComma": "es5", | ||
"semi": true | ||
} | ||
"useTabs": false, | ||
"printWidth": 800, | ||
"tabWidth": 2, | ||
"singleQuote": true, | ||
"trailingComma": "es5", | ||
"semi": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,33 @@ | ||
// The file is here because tsconfig is set to compile all files in src folder, and not the tests folder | ||
import { Localization } from "./index"; | ||
import { Localization } from './index'; | ||
|
||
export const locales = new Localization({ | ||
defaultLocale: 'en', | ||
fallbackLocale: 'en', | ||
locales: { | ||
en: { | ||
hello: 'Hello', | ||
inside: { | ||
world: 'World', | ||
'another/object': { | ||
key: 'key inside' | ||
} | ||
}, | ||
interp: { | ||
hello: 'Hello {{int}}' | ||
} | ||
defaultLocale: 'en', | ||
fallbackLocale: 'en', | ||
locales: { | ||
en: { | ||
hello: 'Hello', | ||
inside: { | ||
world: 'World', | ||
'another/object': { | ||
key: 'key inside', | ||
}, | ||
es: { | ||
hello: 'Hola', | ||
inside: { | ||
world: 'Mundo', | ||
'another/object': { | ||
key: 'key dentro' | ||
} | ||
}, | ||
interp: { | ||
hello: 'Hola {{int}}' | ||
} | ||
} | ||
} | ||
}) | ||
}, | ||
interp: { | ||
hello: 'Hello {{int}}', | ||
}, | ||
}, | ||
es: { | ||
hello: 'Hola', | ||
inside: { | ||
world: 'Mundo', | ||
'another/object': { | ||
key: 'key dentro', | ||
}, | ||
}, | ||
interp: { | ||
hello: 'Hola {{int}}', | ||
}, | ||
}, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
import { it, expect } from "vitest"; | ||
import { locales } from "../src/test"; | ||
import { it, expect } from 'vitest'; | ||
import { locales } from '../src/test'; | ||
|
||
it("should give multiple keys correctly for both langs", () => { | ||
expect(locales.t("hello", {}, 'en')).toBe("Hello"); | ||
expect(locales.t("hello", {}, 'es')).toBe("Hola"); | ||
expect(locales.t("hello")).toBe("Hello"); | ||
expect(locales.t("inside.world", {}, 'en')).toBe("World"); | ||
it('should give multiple keys correctly for both langs', () => { | ||
expect(locales.t('hello', {}, 'en')).toBe('Hello'); | ||
expect(locales.t('hello', {}, 'es')).toBe('Hola'); | ||
expect(locales.t('hello')).toBe('Hello'); | ||
expect(locales.t('inside.world', {}, 'en')).toBe('World'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
import { it, expect } from "vitest"; | ||
import { locales } from "../src/test"; | ||
import { it, expect } from 'vitest'; | ||
import { locales } from '../src/test'; | ||
|
||
it("should return values with interpolations replaced", () => { | ||
expect(locales.t("interp.hello", { int: 'noway' }, 'en')).toBe("Hello noway"); | ||
it('should return values with interpolations replaced', () => { | ||
expect(locales.t('interp.hello', { int: 'noway' }, 'en')).toBe('Hello noway'); | ||
|
||
// test to handle nonexistent interpolaitons, should return the normal {{}} string | ||
expect(locales.t("interp.hello", {}, 'en')).toBe("Hello {{int}}"); | ||
expect(locales.t('interp.hello', {}, 'en')).toBe('Hello {{int}}'); | ||
|
||
// check to prevent XSS | ||
expect(locales.t("interp.hello", { int: '<script>alert("XSS")</script>' }, 'en')).toBe(`Hello <script>alert("XSS")</script>`); | ||
}); | ||
expect(locales.t('interp.hello', { int: '<script>alert("XSS")</script>' }, 'en')).toBe(`Hello <script>alert("XSS")</script>`); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
import { it, expect } from "vitest"; | ||
import { locales } from "../src/test.js"; | ||
import { it, expect } from 'vitest'; | ||
import { locales } from '../src/test.js'; | ||
|
||
it("should give multiple keys correctly for both langs", () => { | ||
expect(locales.localizationFor("hello")).toEqual({ | ||
en: "Hello", | ||
es: "Hola", | ||
it('should give multiple keys correctly for both langs', () => { | ||
expect(locales.localizationFor('hello')).toEqual({ | ||
en: 'Hello', | ||
es: 'Hola', | ||
}); | ||
expect(locales.localizationFor("inside.world")).toEqual({ | ||
en: "World", | ||
es: "Mundo", | ||
expect(locales.localizationFor('inside.world')).toEqual({ | ||
en: 'World', | ||
es: 'Mundo', | ||
}); | ||
expect(locales.localizationFor("inside.another/object.key")).toEqual({ | ||
en: "key inside", | ||
es: "key dentro", | ||
expect(locales.localizationFor('inside.another/object.key')).toEqual({ | ||
en: 'key inside', | ||
es: 'key dentro', | ||
}); | ||
}); |
Oops, something went wrong.