import Config from 'react-native-config';

import * as json from './lang/**/*.json'; // eslint-disable-line import/no-unresolved

const translations = {};

Object.keys(json).forEach(filepath => {
	const keys = filepath.split('$');
	// keys[0] = keys[0].replace('_', '-');
	keys.reduce((obj, k, idx) => {
		if (idx === keys.length - 1) {
			Object.assign(obj, json[filepath]);
		} else if (!obj[k]) {
			Object.assign(obj, { [k]: {} });
		}
		return obj[k];
	}, translations);
});

translations.en.urls = {
	privacyUrl: Config.NIXPLAY_PRIVACY_URL,
	tosUrl: Config.NIXPLAY_TOS_URL,
	helpUrl: Config.NIXPLAY_HELP_URL,
	shopUrl: Config.NIXPLAY_SHOP_URL,
	tipsIOS: Config.NIXPLAY_TIPS_IOS_URL,
	tipsAndroid: Config.NIXPLAY_TIPS_ANDROID_URL,
};

export { translations };
