mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-19 15:33:12 +09:00
Add models for accessing and using the icons and locale that's exported when an instance export is runned.
25 lines
476 B
React
25 lines
476 B
React
import React, { useEffect, useState } from "react";
|
|
|
|
|
|
let localeCache = null;
|
|
export function useLocale() {
|
|
let [locale, setLocale] = useState(localeCache || new Map());
|
|
useEffect(() => {
|
|
async function load() {
|
|
let response = await fetch(`${webRoot}export/locale.json`);
|
|
if (response.ok) {
|
|
let data = await response.json();
|
|
localeCache = new Map(data);
|
|
setLocale(localeCache);
|
|
}
|
|
}
|
|
|
|
if (!localeCache) {
|
|
load();
|
|
}
|
|
}, []);
|
|
|
|
return locale;
|
|
}
|
|
|