-
-
Save opyh/fdfc61dde03d13d03b2722d92b7a2dbd to your computer and use it in GitHub Desktop.
Link Translation snippet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function makeid() { | |
var text = ""; | |
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; | |
for (var i = 0; i < 13; i++) | |
text += possible.charAt(Math.floor(Math.random() * possible.length)); | |
return text; | |
} | |
var links = [ | |
{ | |
"order": 0, | |
"label": { | |
"ar": "دليل السفر", | |
"bg": "Пътеводител", | |
"ca": "Guia de viatge", | |
"cs": "Průvodce", | |
"da": "Rejseguide", | |
"de": "Reiseführer", | |
"el": "Ταξιδιωτικός οδηγός", | |
"es": "Guía turística", | |
"fi": "Matkaopas", | |
"fr": "Guide de voyage", | |
"he": "מדריך נסיעה", | |
"hu": "Útikalauz", | |
"it": "Guida viaggi", | |
"ja": "旅行ガイド", | |
"ko": "여행 가이드", | |
"mn": "Аялалын хөтөч", | |
"nl": "Reisgids", | |
"no": "Reiseguide", | |
"pl": "Przewodnik turystyczny", | |
"pt": "Guia de viagens", | |
"ro": "Ghid turistic", | |
"ru": "Путеводитель", | |
"sk": "Cestovný sprievodca", | |
"sv": "Reseguide", | |
"tr": "Gezi rehberi", | |
"zh_TW": "旅行指南" | |
}, | |
"url": { | |
"en_US": "https://travelable.info/" | |
} | |
}, | |
{ | |
"order": 1, | |
"label": { | |
"ar": "شارك في العمل", | |
"bg": "Включете се", | |
"ca": "Involucrar-se", | |
"cs": "Zapojte se", | |
"da": "Bliv involveret", | |
"de": "Mitmachen", | |
"el": "Συμμετέχετε", | |
"es": "Participar", | |
"fi": "Osallistu", | |
"fr": "S'impliquer", | |
"he": "להתערב", | |
"hu": "Vegyél részt", | |
"it": "Partecipa", | |
"ja": "参加しましょう", | |
"ko": "참여하기", | |
"mn": "Оруулах ", | |
"nl": "Doe mee", | |
"no": "Bli involvert", | |
"pl": "Zaangażuj się", | |
"pt": "Envolva-se", | |
"ro": "Implică-te", | |
"ru": "Поучаствуйте", | |
"sk": "Zapojte sa", | |
"sv": "Bli delaktig", | |
"tr": "Siz de katılın", | |
"zh_TW": "參與其中" | |
}, | |
"url": { | |
"en_US": "https://news.wheelmap.org/en/wheelmap-ambassador/", | |
"de_DE": "https://news.wheelmap.org/wheelmap-ambassador/" | |
} | |
}, | |
{ | |
"order": 2, | |
"label": { | |
"ar": "أخبار", | |
"bg": "Новини", | |
"ca": "Noticies", | |
"cs": "Zprávy", | |
"da": "Nyheder", | |
"el": "Ειδήσεις", | |
"es": "Noticias", | |
"fi": "Uutiset", | |
"fr": "Nouvelles", | |
"he": "חדשות", | |
"hu": "Hírek", | |
"it": "Notizie", | |
"ja": "ニュース", | |
"ko": "뉴스", | |
"mn": "Мэдээ", | |
"nl": "Nieuws", | |
"no": "Nyheter", | |
"pl": "Aktualności", | |
"pt": "Novidades", | |
"ro": "Ştiri", | |
"ru": "Новости", | |
"sk": "Novinky", | |
"sv": "Nyheter", | |
"tr": "Haberler", | |
"zh_TW": "新消息" | |
}, | |
"url": { | |
"en_US": "https://news.wheelmap.org/en/#news", | |
"de_DE": "https://news.wheelmap.org/#news" | |
} | |
}, | |
{ | |
"order": 3, | |
"label": { | |
"ar": "تعليقات صحفية", | |
"bg": "Преса", | |
"ca": "Premsa", | |
"cs": "Tisk", | |
"da": "Presse", | |
"de": "Presse", | |
"el": "Τύπος", | |
"es": "Prensa", | |
"fi": "Media", | |
"fr": "Presse", | |
"he": "לחץ", | |
"hu": "Sajtó", | |
"it": "Stampa", | |
"ja": "押す", | |
"ko": "보도자료", | |
"mn": "Хэвлэх", | |
"nl": "Pers", | |
"no": "Presse", | |
"pl": "Prasa", | |
"pt": "Imprensa", | |
"ro": "Presa", | |
"ru": "Нажмите", | |
"sk": "Stlačiť", | |
"sv": "Media", | |
"tr": "Basın", | |
"zh_TW": "新聞" | |
}, | |
"url": { | |
"en_US": "https://news.wheelmap.org/en/press/", | |
"de_DE": "https://news.wheelmap.org/press/" | |
} | |
}, | |
{ | |
"order": 4, | |
"label": { | |
"ar": "الاتصال بنا", | |
"bg": "Контакт", | |
"ca": "Contacte", | |
"cs": "Kontakt", | |
"da": "Kontakt", | |
"de": "Kontakt", | |
"el": "Επικοινωνία", | |
"es": "Contacto", | |
"fi": "Yhteys", | |
"he": "צור קשר", | |
"hu": "Kapcsolat", | |
"it": "Contatta", | |
"ja": "連絡先", | |
"ko": "연락처", | |
"mn": "Холбоо барих", | |
"no": "Kontakt", | |
"pl": "Kontakt", | |
"pt": "Contacto", | |
"ru": "Контакты", | |
"sk": "Kontakt", | |
"sv": "Kontakta", | |
"tr": "İletişim", | |
"zh_TW": "聯繫" | |
}, | |
"url": { | |
"en_US": "https://news.wheelmap.org/en/contact/", | |
"de_DE": "https://news.wheelmap.org/contact/" | |
} | |
}, | |
{ | |
"order": 5, | |
"label": { | |
"ar": "طباعة", | |
"bg": "Данни за издателя", | |
"ca": "Peu de pagina", | |
"cs": "Otisk", | |
"da": "Aftryk", | |
"de": "Impressum", | |
"el": "Αποτύπωμα", | |
"es": "Aviso legal", | |
"fi": "Tietoa", | |
"fr": "Impression", | |
"he": "חותם", | |
"hu": "Impresszum", | |
"it": "Impronta", | |
"ja": "インプリント", | |
"ko": "인쇄", | |
"mn": "Дардас", | |
"nl": "Colofon", | |
"no": "Avtrykk", | |
"pl": "Informacje prawne", | |
"pt": "Sobre", | |
"ro": "Imprimeu", | |
"ru": "Импринт", | |
"sk": "Stopa", | |
"sv": "Om oss", | |
"tr": "Yayıncı", | |
"zh_TW": "版本說明" | |
}, | |
"url": { | |
"en_US": "https://news.wheelmap.org/en/imprint/", | |
"de_DE": "https://news.wheelmap.org/imprint/" | |
} | |
}, | |
{ | |
"order": 6, | |
"label": { | |
"ar": "الأسئلة المتكررة", | |
"bg": "ЧЗВ", | |
"ca": "PMF", | |
"el": "Συχνές Ερωτήσεις", | |
"es": "Preguntas frecuentes", | |
"fi": "UKK", | |
"he": "שאלות נפוצות", | |
"hu": "GYIK", | |
"ja": "FAQ(よくある質問)", | |
"mn": "Түгээмэл Асуулт Хариулт", | |
"pt": "Perguntas Frequentes", | |
"ru": "ЧаВО", | |
"sk": "Častlo kladené otázky", | |
"sv": "Frågor & Svar", | |
"tr": "SSS", | |
"zh_TW": "常見問題" | |
}, | |
"url": { | |
"en_US": "https://news.wheelmap.org/en/FAQ/", | |
"de_DE": "https://news.wheelmap.org/FAQ/" | |
} | |
} | |
] | |
.map((link, order) => Object.assign(link, { order, _id: makeid(), appId: 'localhost' })) | |
.forEach(link => db.AppLinks.insert(link)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const keys = [ | |
{ | |
label: { en_US: 'Travel guide' }, | |
url: { | |
en_US: 'https://travelable.info/', | |
}, | |
}, | |
{ | |
label: { en_US: 'Get involved' }, | |
url: { | |
en_US: 'https://news.wheelmap.org/en/wheelmap-ambassador/', | |
de_DE: 'https://news.wheelmap.org/wheelmap-ambassador/', | |
}, | |
}, | |
{ | |
label: { en_US: 'News' }, | |
url: { | |
en_US: 'https://news.wheelmap.org/en/#news', | |
de_DE: 'https://news.wheelmap.org/#news', | |
}, | |
}, | |
{ | |
label: { en_US: 'Press' }, | |
url: { | |
en_US: 'https://news.wheelmap.org/en/press/', | |
de_DE: 'https://news.wheelmap.org/press/', | |
}, | |
}, | |
{ | |
label: { en_US: 'Contact' }, | |
url: { | |
en_US: 'https://news.wheelmap.org/en/contact/', | |
de_DE: 'https://news.wheelmap.org/contact/', | |
}, | |
}, | |
{ | |
label: { en_US: 'Imprint' }, | |
url: { | |
en_US: 'https://news.wheelmap.org/en/imprint/', | |
de_DE: 'https://news.wheelmap.org/imprint/', | |
}, | |
}, | |
{ | |
label: { en_US: 'FAQ' }, | |
url: { | |
en_US: 'https://news.wheelmap.org/en/FAQ/', | |
de_DE: 'https://news.wheelmap.org/FAQ/', | |
}, | |
}, | |
]; | |
const results = keys.map((element, order) => { | |
const result = { | |
label: {}, | |
url: element.url, | |
}; | |
for (const lang in translations) { | |
const t = translations[lang]; | |
const label = element.label.en_US; | |
const translation = get(translations, [lang, 'translations', '', label, 'msgstr', 0]); | |
if (translation && translation !== label) { | |
result.label[t.headers.language] = translation; | |
} | |
} | |
return result; | |
}); | |
console.log(JSON.stringify(results, null, 4)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add the first code snippet inside
i18n.js
to generate translated links. Add the result to the second file.Then open a MongoDB shell and execute
load('addlinkstodb.js')
in it to add these links.