import i18n from '../i18n';
export const getLink = tech => {
+ if (tech.type === 'dungeon') {
+ return `/dungeons/${tech.name}`;
+ }
+ if (tech.type === 'location') {
+ return `/locations/${tech.name}`;
+ }
if (tech.type === 'mode') {
return `/modes/${tech.name}`;
}
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) {