mirror of
https://github.com/elk-zone/elk.git
synced 2024-11-23 18:05:25 +03:00
feat(docs): allow edit any locale file (#2099)
This commit is contained in:
parent
f635e0a634
commit
69f9004917
5 changed files with 42 additions and 13 deletions
|
@ -9,12 +9,12 @@ interface LocaleObjectData extends LocaleObject {
|
||||||
pluralRule?: PluralizationRule
|
pluralRule?: PluralizationRule
|
||||||
}
|
}
|
||||||
|
|
||||||
const countryLocaleVariants: Record<string, LocaleObjectData[]> = {
|
export const countryLocaleVariants: Record<string, (LocaleObjectData & { country?: boolean }) []> = {
|
||||||
ar: [
|
ar: [
|
||||||
// ar.json contains ar-EG translations
|
// ar.json contains ar-EG translations
|
||||||
// { code: 'ar-DZ', name: 'Arabic (Algeria)' },
|
// { code: 'ar-DZ', name: 'Arabic (Algeria)' },
|
||||||
// { code: 'ar-BH', name: 'Arabic (Bahrain)' },
|
// { code: 'ar-BH', name: 'Arabic (Bahrain)' },
|
||||||
{ code: 'ar-EG', name: 'العربية' },
|
{ country: true, code: 'ar-EG', name: 'العربية' },
|
||||||
// { code: 'ar-EG', name: 'Arabic (Egypt)' },
|
// { code: 'ar-EG', name: 'Arabic (Egypt)' },
|
||||||
// { code: 'ar-IQ', name: 'Arabic (Iraq)' },
|
// { code: 'ar-IQ', name: 'Arabic (Iraq)' },
|
||||||
// { code: 'ar-JO', name: 'Arabic (Jordan)' },
|
// { code: 'ar-JO', name: 'Arabic (Jordan)' },
|
||||||
|
@ -32,13 +32,13 @@ const countryLocaleVariants: Record<string, LocaleObjectData[]> = {
|
||||||
],
|
],
|
||||||
en: [
|
en: [
|
||||||
// en.json contains en-US translations
|
// en.json contains en-US translations
|
||||||
{ code: 'en-US', name: 'English (US)' },
|
{ country: true, code: 'en-US', name: 'English (US)' },
|
||||||
{ code: 'en-GB', name: 'English (UK)' },
|
{ code: 'en-GB', name: 'English (UK)' },
|
||||||
],
|
],
|
||||||
ca: [
|
ca: [
|
||||||
// ca.json contains ca-ES translations
|
// ca.json contains ca-ES translations
|
||||||
// { code: 'ca-AD', name: 'Català (Andorra)' },
|
// { code: 'ca-AD', name: 'Català (Andorra)' },
|
||||||
{ code: 'ca-ES', name: 'Català (Espanya)' },
|
{ country: true, code: 'ca-ES', name: 'Català (Espanya)' },
|
||||||
{ code: 'ca-valencia', name: 'Català (valencià)' },
|
{ code: 'ca-valencia', name: 'Català (valencià)' },
|
||||||
// { code: 'ca-FR', name: 'Català (França)' },
|
// { code: 'ca-FR', name: 'Català (França)' },
|
||||||
// { code: 'ca-IT', name: 'Català (Itàlia)' },
|
// { code: 'ca-IT', name: 'Català (Itàlia)' },
|
||||||
|
@ -52,7 +52,7 @@ const countryLocaleVariants: Record<string, LocaleObjectData[]> = {
|
||||||
// { code: 'es-CR', name: 'Español (Costa Rica)' },
|
// { code: 'es-CR', name: 'Español (Costa Rica)' },
|
||||||
// { code: 'es-DO', name: 'Español (República Dominicana)' },
|
// { code: 'es-DO', name: 'Español (República Dominicana)' },
|
||||||
// { code: 'es-EC', name: 'Español (Ecuador)' },
|
// { code: 'es-EC', name: 'Español (Ecuador)' },
|
||||||
{ code: 'es-ES', name: 'Español (España)' },
|
{ country: true, code: 'es-ES', name: 'Español (España)' },
|
||||||
// TODO: Support es-419, if we include spanish country variants remove also fix on utils/language.ts module
|
// TODO: Support es-419, if we include spanish country variants remove also fix on utils/language.ts module
|
||||||
{ code: 'es-419', name: 'Español (Latinoamérica)' },
|
{ code: 'es-419', name: 'Español (Latinoamérica)' },
|
||||||
// { code: 'es-GT', name: 'Español (Guatemala)' },
|
// { code: 'es-GT', name: 'Español (Guatemala)' },
|
||||||
|
@ -69,7 +69,7 @@ const countryLocaleVariants: Record<string, LocaleObjectData[]> = {
|
||||||
],
|
],
|
||||||
pt: [
|
pt: [
|
||||||
// pt.json contains pt-PT translations
|
// pt.json contains pt-PT translations
|
||||||
{ code: 'pt-PT', name: 'Português (Portugal)' },
|
{ country: true, code: 'pt-PT', name: 'Português (Portugal)' },
|
||||||
{ code: 'pt-BR', name: 'Português (Brasil)' },
|
{ code: 'pt-BR', name: 'Português (Brasil)' },
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,7 +107,7 @@ async function copyToClipboard() {
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<template v-for="({ title, file, translated, missing, outdated, total, isSource }, key) in localesStatuses" :key="key">
|
<template v-for="({ title, useFile, translated, missing, outdated, total, isSource }, key) in localesStatuses" :key="key">
|
||||||
<tr
|
<tr
|
||||||
v-if="totalReference > 0"
|
v-if="totalReference > 0"
|
||||||
:class="[{ expandable: !isSource }]"
|
:class="[{ expandable: !isSource }]"
|
||||||
|
@ -121,11 +121,25 @@ async function copyToClipboard() {
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<template v-if="isSource">
|
<template v-if="isSource">
|
||||||
<td colspan="5" class="source-text">
|
<td colspan="4" class="source-text">
|
||||||
<div>
|
<div>
|
||||||
{{ total }} keys as source
|
{{ total }} keys as source
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
|
<td>
|
||||||
|
<NuxtLink
|
||||||
|
:href="`https://pr.new/github.com/elk-zone/elk/tree/main/locales/${useFile}`"
|
||||||
|
target="_blank"
|
||||||
|
class="codeflow"
|
||||||
|
title="Raise a PR with Codeflow (opens in new window)"
|
||||||
|
@click.stop
|
||||||
|
>
|
||||||
|
Edit
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24">
|
||||||
|
<path fill="currentColor" d="M5 21q-.825 0-1.413-.587Q3 19.825 3 19V5q0-.825.587-1.413Q4.175 3 5 3h7v2H5v14h14v-7h2v7q0 .825-.587 1.413Q19.825 21 19 21Zm4.7-5.3l-1.4-1.4L17.6 5H14V3h7v7h-2V6.4Z" />
|
||||||
|
</svg>
|
||||||
|
</NuxtLink>
|
||||||
|
</td>
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<td>
|
<td>
|
||||||
|
@ -140,8 +154,7 @@ async function copyToClipboard() {
|
||||||
<td><strong>{{ `${total}` }}</strong></td>
|
<td><strong>{{ `${total}` }}</strong></td>
|
||||||
<td>
|
<td>
|
||||||
<NuxtLink
|
<NuxtLink
|
||||||
v-if="outdated.length > 0 || missing.length > 0"
|
:href="`https://pr.new/github.com/elk-zone/elk/tree/main/locales/${useFile}`"
|
||||||
:href="`https://pr.new/github.com/elk-zone/elk/tree/main/locales/${file}`"
|
|
||||||
target="_blank"
|
target="_blank"
|
||||||
class="codeflow"
|
class="codeflow"
|
||||||
title="Raise a PR with Codeflow (opens in new window)"
|
title="Raise a PR with Codeflow (opens in new window)"
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
export interface LocaleEntry {
|
export interface LocaleEntry {
|
||||||
title: string
|
title: string
|
||||||
file: string
|
file: string
|
||||||
|
useFile: string
|
||||||
translated: string[]
|
translated: string[]
|
||||||
missing: string[]
|
missing: string[]
|
||||||
outdated: string[]
|
outdated: string[]
|
||||||
|
|
|
@ -98,6 +98,8 @@
|
||||||
"error": "ERROR",
|
"error": "ERROR",
|
||||||
"fetching": "Cargando...",
|
"fetching": "Cargando...",
|
||||||
"in": "en",
|
"in": "en",
|
||||||
|
"no_bookmarks": "Sin publicaciones marcadas todavía",
|
||||||
|
"no_favourites": "Sin publicaciones favoritas todavía",
|
||||||
"not_found": "404 No Encontrado",
|
"not_found": "404 No Encontrado",
|
||||||
"offline_desc": "Al parecer no tienes conexión a internet. Por favor, comprueba tu conexión a la red."
|
"offline_desc": "Al parecer no tienes conexión a internet. Por favor, comprueba tu conexión a la red."
|
||||||
},
|
},
|
||||||
|
@ -211,7 +213,7 @@
|
||||||
"title": "Acciones"
|
"title": "Acciones"
|
||||||
},
|
},
|
||||||
"media": {
|
"media": {
|
||||||
"title": "Media"
|
"title": "Multimedia"
|
||||||
},
|
},
|
||||||
"navigation": {
|
"navigation": {
|
||||||
"go_to_home": "Inicio",
|
"go_to_home": "Inicio",
|
||||||
|
@ -293,6 +295,7 @@
|
||||||
"followed_you_count": "{0} personas te siguieron|{0} persona te siguió|{0} personas te siguieron",
|
"followed_you_count": "{0} personas te siguieron|{0} persona te siguió|{0} personas te siguieron",
|
||||||
"missing_type": "MISSING notification.type:",
|
"missing_type": "MISSING notification.type:",
|
||||||
"reblogged_post": "retooteó tu publicación",
|
"reblogged_post": "retooteó tu publicación",
|
||||||
|
"reported": "{0} reportó {1}",
|
||||||
"request_to_follow": "ha solicitado seguirte",
|
"request_to_follow": "ha solicitado seguirte",
|
||||||
"signed_up": "registrado",
|
"signed_up": "registrado",
|
||||||
"update_status": "ha actualizado su publicación"
|
"update_status": "ha actualizado su publicación"
|
||||||
|
@ -444,12 +447,14 @@
|
||||||
"hide_boost_count": "Ocultar contador de retoots",
|
"hide_boost_count": "Ocultar contador de retoots",
|
||||||
"hide_favorite_count": "Ocultar número de publicaciones favoritas",
|
"hide_favorite_count": "Ocultar número de publicaciones favoritas",
|
||||||
"hide_follower_count": "Ocultar número de seguidores",
|
"hide_follower_count": "Ocultar número de seguidores",
|
||||||
|
"hide_news": "Ocultar noticias",
|
||||||
"hide_reply_count": "Ocultar número de respuestas",
|
"hide_reply_count": "Ocultar número de respuestas",
|
||||||
"hide_translation": "Ocultar traducción",
|
"hide_translation": "Ocultar traducción",
|
||||||
"hide_username_emojis": "Ocultar emojis en el nombre de usuario",
|
"hide_username_emojis": "Ocultar emojis en el nombre de usuario",
|
||||||
"hide_username_emojis_description": "Oculta los emojis de los nombres de usuarios en la línea de tiempo. Los emojis permanecerán visibles en sus perfiles.",
|
"hide_username_emojis_description": "Oculta los emojis de los nombres de usuarios en la línea de tiempo. Los emojis permanecerán visibles en sus perfiles.",
|
||||||
"label": "Preferencias",
|
"label": "Preferencias",
|
||||||
"title": "Funcionalidades experimentales",
|
"title": "Funcionalidades experimentales",
|
||||||
|
"use_star_favorite_icon": "Utilizar icono de estrella para favoritos",
|
||||||
"user_picker": "Selector de usuarios",
|
"user_picker": "Selector de usuarios",
|
||||||
"virtual_scroll": "Desplazamiento virtual",
|
"virtual_scroll": "Desplazamiento virtual",
|
||||||
"wellbeing": "Bienestar",
|
"wellbeing": "Bienestar",
|
||||||
|
@ -523,6 +528,7 @@
|
||||||
"replying_to": "Respondiendo a {0}",
|
"replying_to": "Respondiendo a {0}",
|
||||||
"show_full_thread": "Mostrar hilo completo",
|
"show_full_thread": "Mostrar hilo completo",
|
||||||
"someone": "alguien",
|
"someone": "alguien",
|
||||||
|
"spoiler_media_hidden": "Multimedia oculta",
|
||||||
"spoiler_show_less": "Mostrar menos",
|
"spoiler_show_less": "Mostrar menos",
|
||||||
"spoiler_show_more": "Mostrar más",
|
"spoiler_show_more": "Mostrar más",
|
||||||
"thread": "Hilo",
|
"thread": "Hilo",
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { Buffer } from 'node:buffer'
|
||||||
import flatten from 'flat'
|
import flatten from 'flat'
|
||||||
import { createResolver } from '@nuxt/kit'
|
import { createResolver } from '@nuxt/kit'
|
||||||
import fs from 'fs-extra'
|
import fs from 'fs-extra'
|
||||||
import { currentLocales } from '../config/i18n'
|
import { countryLocaleVariants, currentLocales } from '../config/i18n'
|
||||||
import type { LocaleEntry } from '../docs/types'
|
import type { LocaleEntry } from '../docs/types'
|
||||||
import type { ElkTranslationStatus } from '~/types/translation-status'
|
import type { ElkTranslationStatus } from '~/types/translation-status'
|
||||||
|
|
||||||
|
@ -63,10 +63,11 @@ async function prepareTranslationStatus() {
|
||||||
const entries: Record<string, any> = await readI18nFile(sourceLanguageLocale[1])
|
const entries: Record<string, any> = await readI18nFile(sourceLanguageLocale[1])
|
||||||
const flatEntries = flatten<typeof entries, Record<string, string>>(entries)
|
const flatEntries = flatten<typeof entries, Record<string, string>>(entries)
|
||||||
const total = Object.keys(flatEntries).length
|
const total = Object.keys(flatEntries).length
|
||||||
const data: Record<string, LocaleEntry> = {
|
const data: Record<string, LocaleEntry & { useFile: string }> = {
|
||||||
en: {
|
en: {
|
||||||
translated: [],
|
translated: [],
|
||||||
file: 'en.json',
|
file: 'en.json',
|
||||||
|
useFile: 'en.json',
|
||||||
missing: [],
|
missing: [],
|
||||||
outdated: [],
|
outdated: [],
|
||||||
title: 'English (source)',
|
title: 'English (source)',
|
||||||
|
@ -77,8 +78,16 @@ async function prepareTranslationStatus() {
|
||||||
|
|
||||||
await Promise.all(localeData.filter(l => l[0] !== 'en-US').map(async ([code, file, title]) => {
|
await Promise.all(localeData.filter(l => l[0] !== 'en-US').map(async ([code, file, title]) => {
|
||||||
console.info(`Comparing ${code}...`, title)
|
console.info(`Comparing ${code}...`, title)
|
||||||
|
let useFile = file[file.length - 1]
|
||||||
|
const entry = countryLocaleVariants[file[0].slice(0, file[0].indexOf('.'))]
|
||||||
|
if (entry) {
|
||||||
|
const countryFile = entry.find(e => e.code === code && e.country === true)
|
||||||
|
if (countryFile)
|
||||||
|
useFile = file[0]
|
||||||
|
}
|
||||||
data[code] = {
|
data[code] = {
|
||||||
title,
|
title,
|
||||||
|
useFile,
|
||||||
file: Array.isArray(file) ? file[file.length - 1] : file,
|
file: Array.isArray(file) ? file[file.length - 1] : file,
|
||||||
translated: [],
|
translated: [],
|
||||||
missing: [],
|
missing: [],
|
||||||
|
|
Loading…
Reference in a new issue