]> git.localhorst.tv Git - alttp.git/blob - resources/js/helpers/Technique.js
add tech index
[alttp.git] / resources / js / helpers / Technique.js
1 export const getTranslation = (tech, prop, lang) => {
2         const direct = tech.translations.find(t => t.locale === lang);
3         if (direct) {
4                 return direct[prop];
5         }
6         const sameLang = tech.translations.find(t => t.locale.substr(0, 2) === lang.substr(0, 2));
7         if (sameLang) {
8                 return sameLang[prop];
9         }
10         return tech[prop];
11 };
12
13 export const compareTranslation = (prop, lang) => (a, b) =>
14         getTranslation(a, prop, lang).localeCompare(getTranslation(b, prop, lang));
15
16 export default {
17         getTranslation,
18 };