Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add spanish language support #420

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/Feature/src/FeatureList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class="ob-gradient-plate opacity-90 relative z-10 bg-ob-deep-900 rounded-2xl flex justify-start items-end px-6 pb-10 shadow-md"
>
<h2 class="text-3xl pb-8 lg:pb-14">
<p :style="gradientText">EDITOR'S SELECTION</p>
<p :style="gradientText">{{ t('home.editor_selection') }}</p>
<span class="relative text-lg text-ob-bright font-semibold">
<SvgIcon class="inline-block" icon-class="hot" stroke="white" />
{{ t('home.recommended') }}
Expand Down
4 changes: 4 additions & 0 deletions src/components/Header/src/Controls.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,15 @@
<span v-if="$i18n.locale == 'zh-CN'">简体</span>
<span v-if="$i18n.locale == 'zh-TW'">繁體</span>
<span v-if="$i18n.locale == 'en'">En</span>
<span v-if="$i18n.locale == 'es'">Es</span>
</span>
<DropdownMenu>
<DropdownItem name="en" :active="currentLocale === 'en'">
English
</DropdownItem>
<DropdownItem name="es" :active="currentLocale === 'es'">
Español
</DropdownItem>
<DropdownItem name="zh-CN" :active="currentLocale === 'zh-CN'">
简体
</DropdownItem>
Expand Down
18 changes: 18 additions & 0 deletions src/components/MobileMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@
>
{{ route.i18n.en }}
</span>
<span
class="relative z-50"
v-else-if="$i18n.locale === 'es' && route.i18n.es"
>
{{ route.i18n.es }}
</span>
<span class="relative z-50" v-else>{{ route.name }}</span>
</div>
<Dropdown
Expand All @@ -104,6 +110,12 @@
>
{{ route.i18n.en }}
</span>
<span
class="relative z-50"
v-else-if="$i18n.locale === 'es' && route.i18n.es"
>
{{ route.i18n.es }}
</span>
<span class="relative z-50" v-else>{{ route.name }}</span>
<DropdownMenu expand>
<DropdownItem
Expand All @@ -129,6 +141,12 @@
>
{{ sub.i18n.en }}
</span>
<span
class="relative z-50"
v-else-if="$i18n.locale === 'es' && sub.i18n.es"
>
{{ sub.i18n.es }}
</span>
<span class="relative z-50" v-else>{{ sub.name }}</span>
</DropdownItem>
</DropdownMenu>
Expand Down
1 change: 1 addition & 0 deletions src/locales/languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"not-found": "Page not found"
},
"home": {
"editor_selection": "EDITOR'S SELECTION",
"recommended": "Feature Articles"
},
"titles": {
Expand Down
92 changes: 92 additions & 0 deletions src/locales/languages/es.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{
"menu": {
"home": "Inicio",
"about": "Acerca de",
"archives": "Archivo",
"categories": "Categorias",
"tags": "Etiquetas",
"post": "Artículos",
"search": "Resultados de la búsqueda",
"message-board": "Centro de mensajes",
"not-found": "Página no encontrada"
},
"home": {
"editor_selection": "SELECCION DEL EDITOR",
"recommended": "Destacados"
},
"titles": {
"articles": "Artículos",
"about": "Acerca de",
"category_list": "Categorias",
"tag_list": "Etiquetas",
"toc": "Tabla de Contenido",
"comment": "Comentarios",
"recent_comment": "Comentarios Recientes"
},
"settings": {
"months": [
"Enero",
"Febrero",
"Marzo",
"Abril",
"Mayo",
"Junio",
"Julio",
"Agosto",
"Septiembre",
"Octubre",
"Noviembre",
"Diciembre"
],
"articles": "Artículos",
"categories": "Categorias",
"tags": "Etiquetas",
"words": "Palabras",
"visitor_count": "Cantidad de visitantes",
"visit_count": "Cantidad de visitas",
"button-all": "Todos",
"paginator": {
"newer": "Pre",
"older": "Siguiente",
"prev": "Anterior",
"next": "Siguiente"
},
"more-tags": "Ver más",
"admin-user": "Dueño",
"shared-on": "",
"recently-search": "Buscado recientemente:",
"search-result": "Encontrados [total] resultados.",
"no-recent-search": "Sin busquedas recientes.",
"no-search-result": "No se encontraron resultados.",
"cmd-to-select": "para seleccionar",
"cmd-to-navigate": "para navegar",
"cmd-to-close": "para cerrar",
"searched-by": "Búsqueda por",
"tips-back-to-top": "Volver arriba",
"tips-open-menu": "Abrir menú",
"tips-back-to-home": "Volver al inicio",
"tips-open-search": "Abrir buscador",
"default-category": "Artículo",
"default-tag": "ninguno",
"empty-tag": "Sin etiquetas.",
"empty-recent-comments": "Sin comentarios.",
"pinned": "Pin",
"featured": "Hot",
"page-views-value": "Visitas a la Página: ",
"site-running-for": "Tiempo de actividad: ",
"site-running-for-unit": "días",
"links": "Links Amigos",
"links-slogan": "Mejorando con cada blogger",
"links-random-visit": "Visitas random",
"links-apply": "Aplicar a lista de amigos",
"links-badge-personal": "Personal",
"links-badge-personal-desc": "Graba cada paso del camino.",
"links-badge-tech": "Tecnología",
"links-badge-tech-desc": "Blogs de tecnología relacionados.",
"links-badge-designer": "Diseñador",
"links-badge-designer-desc": "Blogs de diseño relacionados.",
"links-badge-vip": "Patrocinadores",
"links-badge-vip-desc": "Patrocinadores recientes",
"notification-random-jump": "Elegir un blogger afortunado al que recurrir."
}
}
1 change: 1 addition & 0 deletions src/locales/languages/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"not-found": "无法找到页面"
},
"home": {
"editor_selection": "EDITOR'S SELECTION",
"recommended": "推荐文章"
},
"titles": {
Expand Down
1 change: 1 addition & 0 deletions src/locales/languages/zh-TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"not-found": "無法找到頁面"
},
"home": {
"editor_selection": "EDITOR'S SELECTION",
"recommended": "推薦文章"
},
"titles": {
Expand Down
16 changes: 11 additions & 5 deletions src/models/ThemeConfig.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ export class ThemeMenu implements ObMenu {
i18n: {
'zh-CN': '首页',
'zh-TW': '首頁',
en: 'Home'
en: 'Home',
es: 'Inicio'
}
})
}
Expand All @@ -98,7 +99,8 @@ export class ThemeMenu implements ObMenu {
i18n: {
'zh-CN': '关于',
'zh-TW': '關於',
en: 'About'
en: 'About',
es: 'Acerca de'
}
},
Archives: {
Expand All @@ -107,7 +109,8 @@ export class ThemeMenu implements ObMenu {
i18n: {
'zh-CN': '归档',
'zh-TW': '歸檔',
en: 'Archives'
en: 'Archives',
es: 'Archivos'
}
},
Tags: {
Expand All @@ -116,7 +119,8 @@ export class ThemeMenu implements ObMenu {
i18n: {
'zh-CN': '标签',
'zh-TW': '標簽',
en: 'Tags'
en: 'Tags',
es: 'Etiquetas'
}
},
Links: {
Expand All @@ -125,7 +129,8 @@ export class ThemeMenu implements ObMenu {
i18n: {
'zh-CN': '友情链接',
'zh-TW': '友情鏈接',
en: 'Friend Links'
en: 'Friend Links',
es: 'Links Amigos'
}
}
}
Expand Down Expand Up @@ -157,6 +162,7 @@ export class ThemeMenu implements ObMenu {
}

enum LocalesTypes {
es,
en,
'zh-CN',
'zh-TW'
Expand Down
1 change: 1 addition & 0 deletions src/utils/comments/github-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ export class GithubComment implements RecentComment {
*/
transformTime(lang: Locales): void {
const templates = {
es: 'comentado [TIME]',
en: 'commented [TIME]',
'zh-CN': '[TIME]评论了',
'zh-TW': '[TIME]評論了'
Expand Down
10 changes: 1 addition & 9 deletions src/utils/comments/leancloud-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@
// import request from '@/utils/external-request'
// import { AxiosResponse } from 'axios'
import { formatTime, filterHTMLContent, RecentComment } from '@/utils'
import pack from '../../../package.json'
import { getGravatar, getGravatarUrl } from './gravatar'
import { Locales } from '@/models/ThemeConfig.class'

const VERSION = pack.version
let AV_INITIALIZED = false

/**
Expand All @@ -24,13 +22,6 @@
*/
declare const AV: any

/**
* js-md5 package is imported through CDN.
*
* For version v0.7.3
*/
declare const md5: any

type LeanCloudApiOption = {
/** Application appId from Leancloud. */
appId: string
Expand Down Expand Up @@ -175,7 +166,7 @@
serverURLs: apiURL
})
} catch (e) {
console.warn(e)

Check warning on line 169 in src/utils/comments/leancloud-api.ts

View workflow job for this annotation

GitHub Actions / PR Build Check

[eslint] reported by reviewdog 🐶 Unexpected console statement. Raw Output: {"ruleId":"no-console","severity":1,"message":"Unexpected console statement.","line":169,"column":9,"nodeType":"MemberExpression","messageId":"unexpected","endLine":169,"endColumn":21}
}
}

Expand Down Expand Up @@ -329,6 +320,7 @@
*/
transformTime(lang: Locales): void {
const templates = {
es: 'comentado [TIME]',
en: 'commented [TIME]',
'zh-CN': '[TIME]评论了',
'zh-TW': '[TIME]評論了'
Expand Down
8 changes: 8 additions & 0 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ export function formatTime(
lang: 'en'
}
const languages: Record<Locales, { [type: string]: string }> = {
es: {
seconds: 'hace un momento',
minutes: ' minutos',
hours: ' horas',
days: ' días',
months: ' meses',
years: ' años'
},
en: {
seconds: 'just seconds ago',
minutes: ' minutes ago',
Expand Down
Loading