]> git.localhorst.tv Git - alttp.git/blobdiff - resources/js/helpers/Technique.js
more alternate/canonical links
[alttp.git] / resources / js / helpers / Technique.js
index c1375bb6c787810119c624aa7de5169aafd3e65d..b289341d34833bbb4b99262885522786260da515 100644 (file)
@@ -19,6 +19,18 @@ export const hasRelations = (tech, type) => getRelations(tech, type).length > 0;
 
 export const getLanguages = tech => ['en', ...tech.translations.map(t => t.locale)];
 
+export const getMatchedLocale = (tech, lang) => {
+       const direct = tech.translations.find(t => t.locale === lang);
+       if (direct) {
+               return direct.locale;
+       }
+       const sameLang = tech.translations.find(t => t.locale.substr(0, 2) === lang.substr(0, 2));
+       if (sameLang) {
+               return sameLang.locale;
+       }
+       return 'en';
+};
+
 export const getTranslation = (tech, prop, lang) => {
        const direct = tech.translations.find(t => t.locale === lang);
        if (direct) {