Skip to content

Commit

Permalink
Introduce i18n. (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
daggerok committed Jun 8, 2024
1 parent cfda1e7 commit 2f2e762
Show file tree
Hide file tree
Showing 11 changed files with 107 additions and 16 deletions.
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
# daggerok.github.io blog

<!--
TBD...
-->
Binary file modified bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "index.js",
"scripts": {
"clear": "npm run clean -- package-lock.json node_modules",
"clean": "rimraf -rf .vuepress/.cache .vuepress/.temp .vuepress/dist",
"clean": "rimraf -rf src/.vuepress/.cache src/.vuepress/.temp src/.vuepress/dist",
"dev": "vuepress dev src",
"build": "vuepress build src",
"build-github-pages": "npm run build"
Expand Down
15 changes: 12 additions & 3 deletions src/.vuepress/components/Post.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,28 @@
export default {
name: 'Post',
props: {
path: {
filePathRelative: {
type: String,
required: false,
default: '',
},
lang: {
type: String,
required: true,
},
image: {
path: {
type: String,
default: 'me-2020-11.jpeg',
required: true,
},
title: {
type: String,
required: false,
default: '',
},
image: {
type: String,
default: 'me-2020-11.jpeg',
},
description: {
type: String,
default: '',
Expand Down
23 changes: 19 additions & 4 deletions src/.vuepress/components/Posts.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
<template>
<div>
<h2>Latest</h2>
<h2>
<span v-if="ru">Последние</span>
<span v-else>Latest</span>
</h2>
<p v-if="pages.length" v-for="page in pages">
<Post :path="page.path" :title="page.title" /> &nbsp;
<Post :filePathRelative="page.filePathRelative"
:lang="page.lang"
:path="page.path"
:title="page.title"
/> &nbsp;
</p>
<p v-if="!pages.length">
To be continue...
<span v-if="ru">Продолжение следует...</span>
<span v-else>To be continue...</span>
</p>
</div>
</template>
Expand All @@ -23,14 +31,21 @@ export default {
// markdownBlogFiles() {
// return __MARKDOWN_BLOG_FILES__ || [];
// },
ru() {
return this.$route
&& this.$route.href
&& this.$route.href.indexOf('/ru/') !== -1;
},
pages() {
const pages = usePages();
// console.log('pages:', pages);
// console.log('this.$route:', this.$route);
// console.log('this.$router:', this.$router);
// console.log('this.$router.currentRoute:', this.$router.currentRoute);
// console.log('this.$router.options:', this.$router.options);
return pages;
const langIsRu = page => page.lang.startsWith('ru-');
const langIsNotRu = page => !langIsRu(page);
return this.ru ? pages.filter(langIsRu) : pages.filter(langIsNotRu);
},
},
}
Expand Down
20 changes: 18 additions & 2 deletions src/.vuepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ const themeConfig = {
mediumZoom: true,
backToHome: true,
nprogress: true,
locales: {
'/': {
lang: 'en-US',
},
'/ru/': {
lang: 'ru-RU',
},
},
};

// @ts-ignore
Expand Down Expand Up @@ -46,16 +54,24 @@ export default defineUserConfig({
{ text: 'Home', link: '/' },
{ text: 'Blog', link: firstBlogPath || '/blog/' },
],
locales: {
'/': {
selectLanguageName: 'English'
},
'/ru/': {
selectLanguageName: 'Русский'
},
},
}),
bundler: viteBundler(), // required by plugins => usePagesPlugin
plugins: [
usePagesPlugin({ // see: https://github.com/monsat/vuepress-plugin-use-pages
filter: (page) => page.title !== 'Blog', // fetch non README.md (title: '# Blog') posts
filter: (page) => page.title !== 'Blog' && page.title !== 'Блог', // fetch non README.md (title: '# Blog') posts
sort: (a, b) => {
if (a.path == b.path) return 0;
return (a.path > b.path) ? -1 : 1; // natural descending order: newest pages comes first
},
startsWith: '/blog/', // fetch only matched paths
startsWith: '/', // '/blog/', // fetch only matched paths
file: 'posts.js', // temp file name will be: posts.js
}),
registerComponentsPlugin({
Expand Down
4 changes: 2 additions & 2 deletions src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ features:
- title: work
details: As you might know I'm doing software engineering.
During my career I worked with many people, customers and companies.
I've experience with many different languages, platforms and tools.
I've experience with many different programming languages, platforms and tools.
I learned a lot already and I know that tomorrow I will learn more!
This area is growing fast! So we must develop ourselves
today unless we want to be a dinosaur tomorrow...
Expand All @@ -37,7 +37,7 @@ features:

<!--
# Hello, World! [![GitHub Pages](https://github.com/daggerok/customized-vuepress-2-blog/actions/workflows/ci.yaml/badge.svg)](https://github.com/daggerok/customized-vuepress-2-blog/actions/workflows/ci.yaml)
# Hello, World! [![GitHub Pages](https://github.com/daggerok/daggerok/actions/workflows/ci.yaml/badge.svg)](https://github.com/daggerok/daggerok/actions/workflows/ci.yaml)
I'm Maksim! I do software engineering, music, love and peace...
Expand Down
28 changes: 28 additions & 0 deletions src/ru/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
lang: ru-RU
home: true
heroImage: me-2020-11.jpeg
heroText: Maksim Kostromin
tagline: Я занимаюсь разработкой ПО, трейдингом и музыкой. Я за мир во всем мире, люблю семью, любить и жить 🙂
Этот сайт обо мне, моей жизни, работе и моих интересах.
Я не думаю, что ты найдешь его интересным потому что посты очень специфичны и в большинстве своем
несут характер личных заметок, но если тебе тут что-то пригодится, тогда добро пожаловать! ✌️
features:
- title: жизнь
details: Уже давно я понял, что самое важное в жизни - это семья.
Я люблю свою жену, дочь и сына больше всего на свете.
Я люблю маму, отца и сестру.
Мне нравятся наши друзья и наш круг общения.
Я хочу жить сегодня и я не хочу откладывать ничего с этим связанным на потом.
Жизнь может пройти очень быстро и внезапно закончится.
- title: работа
details: Я занимаюсь разработкой программного обеспечения.
За свою карьеру я работал со многими людьми, заказчиками и компаниями.
У меня есть опыт работы со многими языками программирования, платформами и инструментами.
Я уже многое изучил и я знаю, что изучу еще больше!
Направление информационных технологий развивается очень быстро! Так что я, как и другие люди работающие в
этой сфере должны постоянно развиваться, развиваться сегодня, если только мы не хотим превратиться в
динозавров завтра...
---

<Posts />
11 changes: 11 additions & 0 deletions src/ru/blog/2022-08-08-vuepress-2-getting-started/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
lang: ru-RU
---

# Старт с VuePress 2.x (ru)

В этом гайде описаны кастомные использования функциональностей VuePress 2.x

[[toc]]

## В разработке
9 changes: 9 additions & 0 deletions src/ru/blog/2023-ICT/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
lang: ru-RU
---

# ICT (ru)
Это мои ICT заметки.

## В разработке

7 changes: 7 additions & 0 deletions src/ru/blog/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
lang: ru-RU
---

# Блог

<Posts />

0 comments on commit 2f2e762

Please sign in to comment.