Skip to content

Commit

Permalink
change: locale loader
Browse files Browse the repository at this point in the history
  • Loading branch information
s00d committed Aug 19, 2024
1 parent 7afc350 commit 2ce1cea
Show file tree
Hide file tree
Showing 20 changed files with 228,632 additions and 228,641 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

114,066 changes: 2 additions & 114,064 deletions playground/locales/de.json

Large diffs are not rendered by default.

114,064 changes: 1 addition & 114,063 deletions playground/locales/en.json

Large diffs are not rendered by default.

114,064 changes: 114,063 additions & 1 deletion playground/locales/pages/index/de.json

Large diffs are not rendered by default.

114,064 changes: 114,063 additions & 1 deletion playground/locales/pages/index/en.json

Large diffs are not rendered by default.

File renamed without changes.
90 changes: 89 additions & 1 deletion playground/locales/pages/subpage/de.json
Original file line number Diff line number Diff line change
@@ -1 +1,89 @@
{}
{
"welcome": "Willkommen, {username}! Sie haben {unreadCount} ungelesene Nachrichten.",
"apples": "keine Äpfel | ein Apfel | {count} Äpfel",
"key2": {
"key2": {
"key2": {
"key2": {
"key2": "Dies ist ein tief verschachtelter Übersetzungsschlüssel."
}
}
}
},
"mainHeader": "Willkommen auf unserer Website",
"nav": {
"home": "Startseite",
"about": "Über uns",
"services": "Dienstleistungen",
"contact": "Kontakt"
},
"content": {
"html1": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur euismod, ligula sit amet fermentum elementum, nunc justo dignissim libero, ac dapibus felis velit a nisi. Integer interdum nulla eget arcu facilisis, sed viverra magna venenatis. Praesent volutpat eros vitae velit sollicitudin, sit amet hendrerit purus condimentum. Phasellus bibendum lorem a vehicula ultrices. Aenean ac ligula euismod, finibus erat ut, lacinia ex. Donec quis lorem orci. Sed facilisis felis sed sapien vehicula, nec gravida ipsum pellentesque. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Proin maximus euismod massa, a tempor ipsum ullamcorper sit amet. Fusce pharetra magna in venenatis aliquet. Maecenas vel nisi eget odio feugiat ullamcorper in non risus. Pellentesque nec tellus sapien. Vivamus congue mauris in vestibulum cursus. Etiam scelerisque libero nec arcu consectetur condimentum. Cras et neque risus. Vivamus porta, turpis sit amet viverra pharetra, magna felis iaculis leo, vitae suscipit odio mauris quis orci.",
"html2": "Aenean sed justo non lacus tincidunt malesuada. Mauris interdum diam nec augue laoreet, a lacinia libero auctor. Quisque quis lacus lorem. Sed gravida, eros ut ultricies efficitur, dolor nisl pharetra augue, et suscipit enim augue ut magna. Morbi et orci vitae augue consequat eleifend. Duis bibendum, orci ac volutpat fermentum, ante nunc auctor nisl, et efficitur felis neque nec libero. Integer euismod tincidunt quam, a finibus arcu dapibus vel. Sed malesuada sem ut tortor scelerisque, et suscipit felis tincidunt. Vestibulum tempor velit in risus vehicula, sed volutpat sem placerat. Nunc ut metus id leo cursus vestibulum. Aliquam erat volutpat. Sed faucibus pharetra libero, eget laoreet tortor tristique id. Vivamus in purus urna. Nam nec urna fringilla, scelerisque ligula in, volutpat nulla. Integer et nisl quis ligula tristique interdum ac vel est. Morbi ac tellus sed ipsum tincidunt facilisis. Vestibulum vehicula diam vel nunc feugiat pharetra."
},
"section1": {
"header": "Abschnitt 1: Einführung",
"intro": "Dieser Abschnitt stellt die Hauptkonzepte vor.",
"subsection1": {
"header": "Unterabschnitt 1.1: Hintergrund",
"content": "Dieser Unterabschnitt behandelt die Hintergrundinformationen."
},
"subsection2": {
"header": "Unterabschnitt 1.2: Wichtige Punkte",
"item1": "Wichtiger Punkt eins in diesem Abschnitt.",
"item2": "Wichtiger Punkt zwei mit mehr Details.",
"item3": "Letzter wichtiger Punkt in diesem Unterabschnitt."
}
},
"section2": {
"header": "Abschnitt 2: Details",
"intro": "Hier gehen wir auf die Details des Themas ein.",
"subsection1": {
"header": "Unterabschnitt 2.1: Tiefenanalyse",
"content": "Ein tiefer Einblick in das Thema."
},
"subsection2": {
"header": "Unterabschnitt 2.2: Schritte zur Durchführung",
"step1": "Schritt 1: Erste Einrichtung.",
"step2": "Schritt 2: Zwischenkonfigurationen.",
"step3": "Schritt 3: Den Prozess abschließen."
},
"subsection3": {
"header": "Unterabschnitt 2.3: Wichtige Erkenntnis",
"quote": "Ein wichtiges Zitat, das man sich merken sollte."
}
},
"section3": {
"header": "Abschnitt 3: Schlussfolgerung",
"intro": "Dieser Abschnitt fasst die Diskussion zusammen.",
"subsection1": {
"header": "Unterabschnitt 3.1: Zusammenfassung",
"content": "Zusammenfassung der besprochenen Schlüsselthemen."
},
"subsection2": {
"header": "Unterabschnitt 3.2: Zukünftige Richtungen",
"content": "Vorschläge für zukünftige Arbeiten oder Forschung."
},
"subsection3": {
"header": "Unterabschnitt 3.3: Zusätzliche Ressourcen",
"item1": "Ressource 1: Dokumentation.",
"item2": "Ressource 2: Tutorials.",
"item3": "Ressource 3: Community-Support.",
"item4": "Ressource 4: Weiterführende Literatur."
}
},
"footer": {
"contact": {
"header": "Kontaktinformation",
"address": "Hauptstraße 123, Suite 100",
"city": "Heimatstadt, Deutschland",
"phone": "+49 (555) 123-4567"
},
"links": {
"header": "Schnellzugriff",
"privacy": "Datenschutzrichtlinie",
"terms": "Nutzungsbedingungen",
"faq": "Häufig gestellte Fragen"
}
}
}
90 changes: 89 additions & 1 deletion playground/locales/pages/subpage/ru.json
Original file line number Diff line number Diff line change
@@ -1 +1,89 @@
{}
{
"welcome": "Добро пожаловать, {username}! У вас {unreadCount} непрочитанных сообщений.",
"apples": "нет яблок | одно яблоко | {count} яблок",
"key2": {
"key2": {
"key2": {
"key2": {
"key2": "Это глубоко вложенный ключ перевода."
}
}
}
},
"mainHeader": "Добро пожаловать на наш сайт",
"nav": {
"home": "Главная",
"about": "О нас",
"services": "Услуги",
"contact": "Контакты"
},
"content": {
"html1": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur euismod, ligula sit amet fermentum elementum, nunc justo dignissim libero, ac dapibus felis velit a nisi. Integer interdum nulla eget arcu facilisis, sed viverra magna venenatis. Praesent volutpat eros vitae velit sollicitudin, sit amet hendrerit purus condimentum. Phasellus bibendum lorem a vehicula ultrices. Aenean ac ligula euismod, finibus erat ut, lacinia ex. Donec quis lorem orci. Sed facilisis felis sed sapien vehicula, nec gravida ipsum pellentesque. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Proin maximus euismod massa, a tempor ipsum ullamcorper sit amet. Fusce pharetra magna in venenatis aliquet. Maecenas vel nisi eget odio feugiat ullamcorper in non risus. Pellentesque nec tellus sapien. Vivamus congue mauris in vestibulum cursus. Etiam scelerisque libero nec arcu consectetur condimentum. Cras et neque risus. Vivamus porta, turpis sit amet viverra pharetra, magna felis iaculis leo, vitae suscipit odio mauris quis orci.",
"html2": "Aenean sed justo non lacus tincidunt malesuada. Mauris interdum diam nec augue laoreet, a lacinia libero auctor. Quisque quis lacus lorem. Sed gravida, eros ut ultricies efficitur, dolor nisl pharetra augue, et suscipit enim augue ut magna. Morbi et orci vitae augue consequat eleifend. Duis bibendum, orci ac volutpat fermentum, ante nunc auctor nisl, et efficitur felis neque nec libero. Integer euismod tincidunt quam, a finibus arcu dapibus vel. Sed malesuada sem ut tortor scelerisque, et suscipit felis tincidunt. Vestibulum tempor velit in risus vehicula, sed volutpat sem placerat. Nunc ut metus id leo cursus vestibulum. Aliquam erat volutpat. Sed faucibus pharetra libero, eget laoreet tortor tristique id. Vivamus in purus urna. Nam nec urna fringilla, scelerisque ligula in, volutpat nulla. Integer et nisl quis ligula tristique interdum ac vel est. Morbi ac tellus sed ipsum tincidunt facilisis. Vestibulum vehicula diam vel nunc feugiat pharetra."
},
"section1": {
"header": "Раздел 1: Введение",
"intro": "Этот раздел вводит основные понятия.",
"subsection1": {
"header": "Подраздел 1.1: История вопроса",
"content": "Этот подраздел охватывает основную информацию."
},
"subsection2": {
"header": "Подраздел 1.2: Ключевые моменты",
"item1": "Ключевой момент первый в этом разделе.",
"item2": "Ключевой момент второй с дополнительными деталями.",
"item3": "Последний ключевой момент в этом подразделе."
}
},
"section2": {
"header": "Раздел 2: Подробности",
"intro": "Здесь мы углубляемся в детали темы.",
"subsection1": {
"header": "Подраздел 2.1: Глубокий анализ",
"content": "Глубокое рассмотрение предмета."
},
"subsection2": {
"header": "Подраздел 2.2: Шаги для выполнения",
"step1": "Шаг 1: Первоначальная настройка.",
"step2": "Шаг 2: Промежуточные конфигурации.",
"step3": "Шаг 3: Завершение процесса."
},
"subsection3": {
"header": "Подраздел 2.3: Важные выводы",
"quote": "Значительная цитата, которую стоит запомнить."
}
},
"section3": {
"header": "Раздел 3: Заключение",
"intro": "Этот раздел завершает обсуждение.",
"subsection1": {
"header": "Подраздел 3.1: Резюме",
"content": "Краткое изложение основных обсужденных моментов."
},
"subsection2": {
"header": "Подраздел 3.2: Направления на будущее",
"content": "Предложения для будущей работы или исследований."
},
"subsection3": {
"header": "Подраздел 3.3: Дополнительные ресурсы",
"item1": "Ресурс 1: Документация.",
"item2": "Ресурс 2: Учебные пособия.",
"item3": "Ресурс 3: Сообщество поддержки.",
"item4": "Ресурс 4: Дополнительная литература."
}
},
"footer": {
"contact": {
"header": "Контактная информация",
"address": "Улица Главная, дом 123, офис 100",
"city": "Родной город, Россия",
"phone": "+7 (555) 123-4567"
},
"links": {
"header": "Быстрые ссылки",
"privacy": "Политика конфиденциальности",
"terms": "Условия использования",
"faq": "Часто задаваемые вопросы"
}
}
}
2 changes: 1 addition & 1 deletion playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
},
"dependencies": {
"nuxt": "^3.12.4",
"nuxt-i18n-micro": "^1.1.8"
"nuxt-i18n-micro": "^1.1.9"
}
}
40 changes: 15 additions & 25 deletions playground/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,44 +30,34 @@
v-for="key in generatedKeys"
:key="key"
>
<p>{{ key }}: {{ $t(key) }}</p>
<p>{{ key }}: <span v-if="$has(key)">{{ $t(key) }}</span></p>
</div>
</div>
</template>

<script setup>
import { useI18n } from '#imports'
const { $getLocale, $switchLocale, $getLocales, $localeRoute, $t } = useI18n()
function generateRandomPrefix(maxKeys = 10) {
return `key${Math.floor(Math.random() * maxKeys)}`
}
// Function to generate keys with random prefix up to a certain depth
function generateKeys(depth, maxKeys = 10) {
// Function to generate keys with a fixed pattern
function generateKeys(depth, maxKeys = 4) {
const keys = []
const generate = (currentKey, currentDepth) => {
const generate = (prefix = '', currentDepth = depth) => {
if (currentDepth === 0) {
keys.push(currentKey)
for (let i = 0; i <= maxKeys; i++) {
// Генерируем ключ с инкрементом по последнему элементу
keys.push(`${prefix}key${i}`)
}
return
}
for (let i = 0; i < maxKeys; i++) {
const newKey = `key${i}`
generate(`${currentKey}.${newKey}`, currentDepth - 1)
for (let i = 0; i <= maxKeys; i++) {
// Добавляем к префиксу текущий элемент
generate(`${prefix}key${i}.`, currentDepth - 1)
}
}
// Start with a randomly generated prefix
const prefix = generateRandomPrefix(maxKeys)
generate(prefix, depth)
generate()
return keys
}
// Generate keys up to the maximum depth defined in your translation structure
const generatedKeys = generateKeys(4)
// $defineI18nRoute({
// locales: ['en', 'ru'],
// })
const generatedKeys = ref(generateKeys(4))
</script>
2 changes: 1 addition & 1 deletion playground/pages/page.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div>
<p>{{ $t('key2.key2.key2.key2.key2') }}</p>
<p>{{ $t('key1.key1.key1.key1.key1') }}</p>
<p>Current Locale: {{ $getLocale() }}</p>

<div>
Expand Down
Loading

0 comments on commit 2ce1cea

Please sign in to comment.