-
-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
251 additions
and
51 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
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
export default { | ||
WARNING_DUPLICATE: 'Duplicate {{item}} key found in store: ', | ||
INVALID_STORE: 'Tried to parse a non-existent store.', | ||
INVALID_STORE_REFRESH: 'Tried to refresh invalid store: ', | ||
INVALID_ITEM_SELECTION: 'Invalid item selection.', | ||
PURCHASE_INVALID_STORE: 'tried purchasing an item that does not exist store: ', | ||
SELL_INVALID_ITEM: 'tried selling an invalid item.', | ||
ITEM_OUT_OF_STOCK: 'This item is currently out of stock.', | ||
NOT_ENOUGH_CURRENCY: 'You do not have enough currency to buy this item.', | ||
NOT_ENOUGH_SPACE: 'You do not have enough space in your inventory.', | ||
CANNOT_SELL_ITEM: 'You cannot sell this item.', | ||
ACTION_STORE_NOT_OPEN: 'Tried to perform an action on a store that is not open.', | ||
CHEATER: 'You have been flagged for cheating. You cannot purchase anything.', | ||
RESTRICTED_STORE: 'This store does not accept any items.', | ||
INVALID_ITEM_COUNT: 'You have entered an invalid amount of items.', | ||
HOLLOW_ADMIN: 'As an admin you cannot interact with the economy.' | ||
} as const; |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export default { | ||
game: { | ||
name: 'Kaetram', | ||
description: | ||
"Kaetram is an open-source game-engine created to aid those interested in entering the game development realm. The original idea is based on Little Workshop's demo game - BrowserQuest. The assets have remained the same, but the code itself has been completely wiped and redone from the ground up." | ||
} | ||
} as const; |
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import * as i18next from 'i18next'; | ||
import i18nextBackend from 'i18next-fs-backend'; | ||
|
||
import type { NsInter } from './ns'; | ||
|
||
export let locales = { en: 'en-US', ro: 'ro-RO' }; | ||
export let defaultLocale = 'en'; | ||
|
||
export type Locale = keyof typeof locales; | ||
|
||
await i18next.use(i18nextBackend).init({ | ||
lng: defaultLocale, | ||
fallbackLng: defaultLocale, | ||
preload: Object.keys(locales), | ||
ns: ['translation'], | ||
defaultNS: 'translation', | ||
backend: { loadPath: '{{lng}}/{{ns}}' } | ||
}); | ||
|
||
export let t = < | ||
K extends keyof NsInter[N], | ||
O extends { ns?: keyof NsInter }, | ||
N extends keyof NsInter = O extends { ns: infer N } ? N : 'translation' | ||
>( | ||
key: K, | ||
options?: i18next.TOptions<O & NsInter[N][K]> | ||
) => i18next.t(key as string, options); | ||
|
||
export let dir = (locale: Locale) => i18next.dir(locale); |
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import type Translation from './en/translation'; | ||
import type Store from './en/store'; | ||
import type { TypeOptions } from 'i18next'; | ||
|
||
type DotValue<T extends string> = T extends `${infer L}.${infer R}` | ||
? { [K in L]: DotValue<R> } | ||
: { [K in T]: string }; | ||
|
||
type Prefix = TypeOptions['interpolationPrefix']; | ||
type Suffix = TypeOptions['interpolationSuffix']; | ||
type Interpolation<T> = T extends `${string}${Prefix}${infer I}${Suffix}${infer N}` | ||
? DotValue<I> & Interpolation<N> | ||
: unknown; | ||
|
||
type TraverseInterpolation<T> = T extends string | ||
? Interpolation<T> | ||
: T extends object | ||
? { [K in keyof T]: TraverseInterpolation<T[K]> } | ||
: never; | ||
|
||
type UnionToIntersection<T> = (T extends unknown ? (_: T) => unknown : never) extends ( | ||
_: infer R | ||
) => unknown | ||
? R | ||
: never; | ||
|
||
type DotFlatten<T> = T extends object | ||
? UnionToIntersection< | ||
{ | ||
[K in keyof T]: T[K] extends object | ||
? DotFlatten< | ||
{ | ||
[L in keyof T[K]]: { | ||
[M in `${K & string}.${L & string}`]: DotFlatten<T[K][L]>; | ||
}; | ||
}[keyof T[K]] | ||
> | ||
: T; | ||
}[keyof T] | ||
> | ||
: T; | ||
|
||
export interface Namespace { | ||
translation: typeof Translation; | ||
store: typeof Store; | ||
} | ||
|
||
export type NsInter = { | ||
[K in keyof Namespace]: TraverseInterpolation<DotFlatten<Namespace[K]>>; | ||
}; | ||
|
||
export type { TOptions } from 'i18next'; |
Empty file.
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
Oops, something went wrong.