-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #79 from zhangfisher/3.0
3.0
- Loading branch information
Showing
81 changed files
with
6,972 additions
and
24,590 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
|
||
} |
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,14 @@ | ||
const ISO639 = require("iso-639-1-zh"); | ||
const fs = require("fs"); | ||
|
||
console.log(ISO639.getAllCodes()) // '中文' | ||
|
||
|
||
const langTypes = [] | ||
|
||
fs.writeFileSync("lngTypes",ISO639.getAllCodes().join("' | '")) | ||
|
||
console.log(ISO639.getZhName('zh')) // '中文' | ||
console.log(ISO639.getZhName('es')) // '西班牙语' | ||
console.log(ISO639.getLanguages(['en', 'es'])) | ||
|
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,26 @@ | ||
type LanguageCodes = 'aa' | 'ab' | 'ae' | 'af' | 'ak' | 'am' | 'an' | 'ar' | 'as' | 'av' | 'ay' | 'az' | ||
| 'ba' | 'be' | 'bg' | 'bh' | 'bi' | 'bm' | 'bn' | 'bo' | 'br' | 'bs' | ||
| 'ca' | 'ce' | 'ch' | 'co' | 'cr' | 'cs' | 'cu' | 'cv' | 'cy' | ||
| 'da' | 'de' | 'dv' | 'dz' | ||
| 'ee' | 'el' | 'en' | 'eo' | 'es' | 'et' | 'eu' | ||
| 'fa' | 'ff' | 'fi' | 'fj' | 'fo' | 'fr' | 'fy' | ||
| 'ga' | 'gd' | 'gl' | 'gn' | 'gu' | 'gv' | ||
| 'ha' | 'he' | 'hi' | 'ho' | 'hr' | 'ht' | 'hu' | 'hy' | 'hz' | ||
| 'ia' | 'id' | 'ie' | 'ig' | 'ii' | 'ik' | 'io' | 'is' | 'it' | 'iu' | ||
| 'ja' | 'jv' | ||
| 'ka' | 'kg' | 'ki' | 'kj' | 'kk' | 'kl' | 'km' | 'kn' | 'ko' | 'kr' | 'ks' | 'ku' | 'kv' | 'kw' | 'ky' | ||
| 'la' | 'lb' | 'lg' | 'li' | 'ln' | 'lo' | 'lt' | 'lu' | 'lv' | ||
| 'mg' | 'mh' | 'mi' | 'mk' | 'ml' | 'mn' | 'mr' | 'ms' | 'mt' | 'my' | ||
| 'na' | 'nb' | 'nd' | 'ne' | 'ng' | 'nl' | 'nn' | 'no' | 'nr' | 'nv' | 'ny' | ||
| 'oc' | 'oj' | 'om' | 'or' | 'os' | ||
| 'pa' | 'pi' | 'pl' | 'ps' | 'pt' | ||
| 'qu' | ||
| 'rm' | 'rn' | 'ro' | 'ru' | 'rw' | ||
| 'sa' | 'sc' | 'sd' | 'se' | 'sg' | 'si' | 'sk' | 'sl' | 'sm' | 'sn' | 'so' | 'sq' | 'sr' | 'ss' | 'st' | 'su' | 'sv' | 'sw' | ||
| 'ta' | 'te' | 'tg' | 'th' | 'ti' | 'tk' | 'tl' | 'tn' | 'to' | 'tr' | 'ts' | 'tt' | 'tw' | 'ty' | ||
| 'ug' | 'uk' | 'ur' | 'uz' | ||
| 've' | 'vi' | 'vo' | ||
| 'wa' | 'wo' | ||
| 'xh' | ||
| 'yi' | 'yo' | ||
| 'za' | 'zh' | 'zu' |
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 @@ | ||
["aa","ab","ae","af","ak","am","an","ar","as","av","ay","az","ba","be","bg","bi","bm","bn","bo","br","bs","ca","ce","ch","co","cr","cs","cu","cv","cy","da","de","dv","dz","ee","el","en","eo","es","et","eu","fa","ff","fi","fj","fo","fr","fy","ga","gd","gl","gn","gu","gv","ha","he","hi","ho","hr","ht","hu","hy","hz","ia","id","ie","ig","ii","ik","io","is","it","iu","ja","jv","ka","kg","ki","kj","kk","kl","km","kn","ko","kr","ks","ku","kv","kw","ky","la","lb","lg","li","ln","lo","lt","lu","lv","mg","mh","mi","mk","ml","mn","mr","ms","mt","my","na","nb","nd","ne","ng","nl","nn","no","nr","nv","ny","oc","oj","om","or","os","pa","pi","pl","ps","pt","qu","rm","rn","ro","ru","rw","sa","sc","sd","se","sg","si","sk","sl","sm","sn","so","sq","sr","ss","st","su","sv","sw","ta","te","tg","th","ti","tk","tl","tn","to","tr","ts","tt","tw","ty","ug","uk","ur","uz","ve","vi","vo","wa","wo","xh","yi","yo","za","zh","zu"] |
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,60 @@ | ||
import { VoerkaI18nLanguageLoader } from '@/types' | ||
import { VoerkaI18nScope, VoerkaI18nScopeOptions } from '../scope' | ||
import { VoerkaI18nManager } from "@/manager" | ||
|
||
|
||
export function createVoerkaI18nScope(opts?:Partial<VoerkaI18nScopeOptions>): VoerkaI18nScope { | ||
return new VoerkaI18nScope(Object.assign({ | ||
id: 'test-scope', | ||
debug: false, | ||
library: false, | ||
languages: { | ||
zh: { name: 'Chinese', title: '中文', fallback: 'en', active: true,default: true }, | ||
en: { name: 'English', title: 'English'} | ||
}, | ||
fallback: "en", | ||
messages: { | ||
en: { message: 'Hello' }, | ||
zh: { message: '你好' } | ||
}, | ||
idMap: {}, | ||
storage: undefined, | ||
formatters: {}, | ||
ready: () => {}, | ||
}, opts)) | ||
} | ||
|
||
|
||
export function resetVoerkaI18n() { | ||
try{ | ||
|
||
if(globalThis.VoerkaI18n){ | ||
globalThis.VoerkaI18n.clearLanguage() | ||
} | ||
|
||
// @ts-ignore | ||
delete globalThis.__VoerkaI18nScopes__ | ||
// @ts-ignore | ||
delete globalThis.VoerkaI18n | ||
VoerkaI18nManager.instance = undefined | ||
|
||
}catch{} | ||
} | ||
|
||
|
||
export function getTestStorage(init?:string){ | ||
let saveLanguage:string | undefined= init | ||
return { | ||
get() { return saveLanguage}, | ||
set(_:string,value:string){saveLanguage = value}, | ||
remove(){ saveLanguage = undefined } | ||
} | ||
|
||
} | ||
|
||
|
||
export function getTestLanguageLoader(patchMsgs?:Record<string,any>):VoerkaI18nLanguageLoader{ | ||
return async (language:string,scope:VoerkaI18nScope)=>{ | ||
return Object.assign({},patchMsgs) | ||
} | ||
} |
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
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
Oops, something went wrong.