MCPcopy
hub / github.com/kimlimjustin/xplorer / Translate

Function Translate

src/Components/I18n/i18n.ts:11–32  ·  view source on GitHub ↗
(source: string)

Source from the content-addressed store, hash-verified

9 * @returns {Promise<string>} translated string
10 */
11const Translate = async (source: string): Promise<string> => {
12 // Read available language
13 if (!localesInformation?.LOCALES) {
14 localesInformation = new LocalesAPI();
15 await localesInformation.build();
16 }
17 const lang = (await Storage.get('preference'))?.language ?? navigator.language;
18 for (const locale of Object.values(localesInformation.AVAILABLE_LOCALES)) {
19 // Check if the inputed lang available
20 if (locale === lang) {
21 if (localesInformation.LOCALES[locale]) {
22 // Replace all text
23 Object.keys(localesInformation.LOCALES[locale]).forEach((key) => {
24 if (source === key) source = localesInformation.LOCALES[locale][key];
25 });
26 }
27 // Return translated text
28 return source;
29 }
30 }
31 return source; // Return translated text
32};
33
34export default Translate;

Callers 15

createNewTabFunction · 0.85
TabFunction · 0.85
getFavoritesElementFunction · 0.85
createSidebarFunction · 0.85
FavoritesFunction · 0.85
drivesToElementsFunction · 0.85
sidebarDrivesElementFunction · 0.85
SettingFunction · 0.85
AppearanceFunction · 0.85
PreferenceFunction · 0.85
FileMenuFunction · 0.85
SidebarMenuFunction · 0.85

Calls 2

getMethod · 0.80
buildMethod · 0.45

Tested by

no test coverage detected