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

automatic i18n for the whole website #245

Merged
merged 151 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
151 commits
Select commit Hold shift + click to select a range
bc9c94e
i18n for homepage
rishi-raj-jain Sep 27, 2024
a11c758
Update index.vue
rishi-raj-jain Sep 27, 2024
9ccbcf5
Update Footer.vue
rishi-raj-jain Sep 27, 2024
e819ba3
Update Footer.vue
rishi-raj-jain Sep 27, 2024
e7cd7d1
Update Footer.vue
rishi-raj-jain Sep 27, 2024
49d42ed
Update Footer.vue
rishi-raj-jain Sep 27, 2024
59d2512
bun lock
rishi-raj-jain Sep 28, 2024
6713373
use files
rishi-raj-jain Sep 28, 2024
42ac4b3
use ref
rishi-raj-jain Sep 28, 2024
36c3baa
fix markdown links
rishi-raj-jain Sep 28, 2024
fecee01
run prettier
rishi-raj-jain Sep 28, 2024
3fdf2f4
Update .prettierignore
rishi-raj-jain Sep 28, 2024
47f4335
update deps
rishi-raj-jain Sep 28, 2024
5f02ade
jsons
rishi-raj-jain Sep 29, 2024
93c5d74
prettier
rishi-raj-jain Sep 29, 2024
f6f3516
name the file
rishi-raj-jain Sep 29, 2024
b00ff9b
run prettier
rishi-raj-jain Sep 29, 2024
6444ee6
new lines
rishi-raj-jain Sep 29, 2024
d5a22a0
auto generated file notice
rishi-raj-jain Sep 29, 2024
72c1808
add files
rishi-raj-jain Sep 29, 2024
16409c7
dynamically define the fallbacks
rishi-raj-jain Sep 29, 2024
d2015e6
blog translations
rishi-raj-jain Sep 29, 2024
928ad92
organize imports
rishi-raj-jain Sep 29, 2024
1944daa
remvoe unused
rishi-raj-jain Sep 29, 2024
81b5465
add directory if does not exist
rishi-raj-jain Sep 29, 2024
eb80207
add direcotry and locale
rishi-raj-jain Sep 29, 2024
4059967
use alias
rishi-raj-jain Sep 29, 2024
51c7dd3
add automation for new locale
rishi-raj-jain Sep 30, 2024
99ee149
AGI i18
rishi-raj-jain Sep 30, 2024
e2d58e2
remove build output redir
rishi-raj-jain Sep 30, 2024
fd08106
ran prettier
rishi-raj-jain Sep 30, 2024
0d47826
rest of the pages
rishi-raj-jain Oct 2, 2024
6d4b5d0
add more tags
rishi-raj-jain Oct 2, 2024
2d5d118
use gpy
rishi-raj-jain Oct 2, 2024
833b1fd
run prettier
rishi-raj-jain Oct 2, 2024
f6cf570
remove es for now
rishi-raj-jain Oct 2, 2024
cd9689a
add the imports
rishi-raj-jain Oct 2, 2024
bbf88b6
fix imports
rishi-raj-jain Oct 2, 2024
e309c02
using lang
rishi-raj-jain Oct 4, 2024
b5d9da9
Merge branch 'main' into main
rishi-raj-jain Oct 4, 2024
0e33feb
prettier
rishi-raj-jain Oct 4, 2024
c7bf61d
add more translation
rishi-raj-jain Oct 4, 2024
6ec6dde
mid
rishi-raj-jain Oct 4, 2024
849675a
two more files
rishi-raj-jain Oct 5, 2024
66eedb7
two more files
rishi-raj-jain Oct 5, 2024
6f6e45b
prettier
rishi-raj-jain Oct 5, 2024
297c54f
css changes
rishi-raj-jain Oct 5, 2024
8ba6737
next image
rishi-raj-jain Oct 5, 2024
9b3c6ad
imports
rishi-raj-jain Oct 5, 2024
eec4342
abstract
rishi-raj-jain Oct 5, 2024
1465f05
type for vite info
rishi-raj-jain Oct 5, 2024
574cfd1
ts-ignore
rishi-raj-jain Oct 5, 2024
724b5b6
fix ts ignore
rishi-raj-jain Oct 5, 2024
f74d373
bun install
rishi-raj-jain Oct 5, 2024
493df6c
use dotenv with OPENAI API
rishi-raj-jain Oct 5, 2024
61f7575
locales
rishi-raj-jain Oct 5, 2024
b794e7d
execSync
rishi-raj-jain Oct 5, 2024
4c017e3
fr/contributing
rishi-raj-jain Oct 5, 2024
d6e991e
pages
rishi-raj-jain Oct 5, 2024
122bce5
set up top_app pages
rishi-raj-jain Oct 5, 2024
0824ae0
...
rishi-raj-jain Oct 5, 2024
090fd9c
...
rishi-raj-jain Oct 5, 2024
c84a2ac
...
rishi-raj-jain Oct 5, 2024
1e421a3
pricing
rishi-raj-jain Oct 5, 2024
bf6dbd0
pricing
rishi-raj-jain Oct 5, 2024
5068200
add locale
rishi-raj-jain Oct 5, 2024
c6939e0
pricing
rishi-raj-jain Oct 5, 2024
4083bef
formatting
rishi-raj-jain Oct 5, 2024
dbddc88
comment
rishi-raj-jain Oct 5, 2024
6256a9a
comment
rishi-raj-jain Oct 5, 2024
8499b36
i18n for pages
rishi-raj-jain Oct 5, 2024
f91e5cb
even more
rishi-raj-jain Oct 5, 2024
09b2c81
...
rishi-raj-jain Oct 5, 2024
4a63953
...
rishi-raj-jain Oct 5, 2024
2dc56d0
...
rishi-raj-jain Oct 5, 2024
08ee8d2
...
rishi-raj-jain Oct 5, 2024
c04e63b
...
rishi-raj-jain Oct 5, 2024
d572676
add fr
rishi-raj-jain Oct 5, 2024
a69c67e
add fr
rishi-raj-jain Oct 5, 2024
cb6233c
aup
rishi-raj-jain Oct 5, 2024
178add0
aup
rishi-raj-jain Oct 5, 2024
ac96290
types
rishi-raj-jain Oct 6, 2024
f3d9a2e
even simpler
rishi-raj-jain Oct 6, 2024
b844159
sla
rishi-raj-jain Oct 6, 2024
0f74c92
suppotr-policy.astro
rishi-raj-jain Oct 6, 2024
bf4cd16
oops
rishi-raj-jain Oct 6, 2024
c649f5b
oops
rishi-raj-jain Oct 6, 2024
8f54fa7
preview
rishi-raj-jain Oct 6, 2024
bfa014d
..
rishi-raj-jain Oct 6, 2024
e54cc1d
ignore stuff
rishi-raj-jain Oct 6, 2024
c22b97b
...
rishi-raj-jain Oct 6, 2024
bd8980e
plugin
rishi-raj-jain Oct 6, 2024
88cdbb8
type sense
rishi-raj-jain Oct 6, 2024
faa0705
en
rishi-raj-jain Oct 6, 2024
9ed753e
more
rishi-raj-jain Oct 6, 2024
f3385c7
fix build
rishi-raj-jain Oct 8, 2024
4a7cd53
more changes
rishi-raj-jain Oct 8, 2024
3c368ce
stuff
rishi-raj-jain Oct 8, 2024
59cd31c
...
rishi-raj-jain Oct 8, 2024
367ba16
...
rishi-raj-jain Oct 8, 2024
8f0e2fa
...
rishi-raj-jain Oct 8, 2024
48f9f65
...
rishi-raj-jain Oct 8, 2024
ff6f7c5
...
rishi-raj-jain Oct 8, 2024
4be6575
use middleware more
rishi-raj-jain Oct 10, 2024
db3e7ed
setup new
rishi-raj-jain Oct 10, 2024
fe4d7b5
...
rishi-raj-jain Oct 10, 2024
8cc6126
...
rishi-raj-jain Oct 10, 2024
85b1af4
organize imports
rishi-raj-jain Oct 10, 2024
81f799c
use translation
rishi-raj-jain Oct 10, 2024
5d89200
...
rishi-raj-jain Oct 10, 2024
ceb1ad0
...
rishi-raj-jain Oct 10, 2024
5a5651b
sort imports
rishi-raj-jain Oct 10, 2024
c055bde
return
rishi-raj-jain Oct 10, 2024
6a3f177
register.vue
rishi-raj-jain Oct 10, 2024
da492f0
register.vue
rishi-raj-jain Oct 10, 2024
6a407bf
eula.vue
rishi-raj-jain Oct 10, 2024
bee2313
dpa.vue
rishi-raj-jain Oct 10, 2024
b7b3696
dpa.vue
rishi-raj-jain Oct 10, 2024
1c22d45
dpa.vue
rishi-raj-jain Oct 10, 2024
3d39100
all.vue
rishi-raj-jain Oct 10, 2024
badea0f
all.vue
rishi-raj-jain Oct 10, 2024
76fe9d1
all.vue
rishi-raj-jain Oct 10, 2024
a616be4
all.vue
rishi-raj-jain Oct 10, 2024
ad28c6d
all.vue
rishi-raj-jain Oct 10, 2024
2536ba8
all.vue
rishi-raj-jain Oct 10, 2024
085ce9b
all.vue
rishi-raj-jain Oct 10, 2024
eba16c7
updated bun
rishi-raj-jain Oct 10, 2024
87eb145
all.vue
rishi-raj-jain Oct 11, 2024
c84f54a
all.vue
rishi-raj-jain Oct 11, 2024
a5f1681
all.vue
rishi-raj-jain Oct 11, 2024
ec157f2
all.vue
rishi-raj-jain Oct 11, 2024
860cd6a
all.vue
rishi-raj-jain Oct 11, 2024
64ad044
relative
rishi-raj-jain Oct 11, 2024
7101bd8
all.vue
rishi-raj-jain Oct 11, 2024
7707eec
Merge remote-tracking branch 'upstream/main'
rishi-raj-jain Oct 11, 2024
0219cce
all.vue
rishi-raj-jain Oct 11, 2024
f80425f
all.vue
rishi-raj-jain Oct 11, 2024
ede8e48
note for english translation
rishi-raj-jain Oct 12, 2024
ee2db82
note for english translation
rishi-raj-jain Oct 12, 2024
6b8ac2c
note for english translation
rishi-raj-jain Oct 12, 2024
bd8ed13
note for english translation
rishi-raj-jain Oct 12, 2024
610054f
else if tutorial
rishi-raj-jain Oct 14, 2024
51425c4
else if tutorial
rishi-raj-jain Oct 14, 2024
b505b56
else if tutorial
rishi-raj-jain Oct 14, 2024
e3f8ec5
else if tutorial
rishi-raj-jain Oct 14, 2024
5d81c60
else if tutorial
rishi-raj-jain Oct 14, 2024
b5a0195
else if tutorial
rishi-raj-jain Oct 14, 2024
aa4960a
else if tutorial
rishi-raj-jain Oct 14, 2024
a4a71a6
else if tutorial
rishi-raj-jain Oct 14, 2024
6183217
else if tutorial
rishi-raj-jain Oct 14, 2024
5504b47
else if tutorial
rishi-raj-jain Oct 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 0 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ jobs:
uses: oven-sh/setup-bun@v2
with:
bun-version: latest

- name: Install dependencies
run: bun install
- name: Generate static pages
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ jobs:
uses: oven-sh/setup-bun@v2
with:
bun-version: latest

- name: Install dependencies
run: bun install
- name: Generate static pages
Expand Down
7 changes: 5 additions & 2 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,8 @@ pnpm-debug.log*
# macOS-specific files
.DS_Store

public/**/*
src/content/**/*
**/*.md*
**/*.yml
public/
src/services/locale.ts
src/services/translations.ts
6 changes: 0 additions & 6 deletions .prettierrc

This file was deleted.

6 changes: 6 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"semi": false,
"printWidth": 180,
"singleQuote": true,
"plugins": ["prettier-plugin-astro", "prettier-plugin-tailwindcss", "prettier-plugin-organize-imports"]
}
44 changes: 26 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Capgo website

<a href="https://capgo.app/"><img src='https://raw.githubusercontent.com/Cap-go/capgo/main/assets/capgo_banner.png' alt='Capgo - Instant updates for capacitor'/></a>
<a href="https://capgo.app/"><img src='https://raw.githubusercontent.com/Cap-go/capgo/main/assets/capgo_banner.png' alt='Capgo - Instant updates for capacitor'/></a>
[![Discord](https://badgen.net/badge/icon/discord?icon=discord&label)](https://discord.com/invite/VnYRvBfgA6)
<a href="https://discord.com/invite/VnYRvBfgA6"><img src="https://img.shields.io/discord/912707985829163099?color=%237289DA&label=Discord" alt="Discord">
[![npm](https://img.shields.io/npm/dm/@capgo/website)](https://www.npmjs.com/package/@capgo/website)
Expand All @@ -18,7 +18,7 @@

<h2><a href="https://capgo.app/consulting/">Hire a Capacitor consultant</a></h2>

This is the source code for the Capgo website. It is built using [Astro](https://astro.build/), a new static site generator.
This is the source code for the Capgo website, built with [Astro](https://astro.build/).

## Development

Expand All @@ -37,20 +37,6 @@ The website is deployed to [Cloudflare Pages](https://pages.cloudflare.com/). Th

The source code is licensed under the GNU AFFERO GENERAL PUBLIC license. See the [LICENSE](LICENSE) file for details.

# Astro Starter Kit: Basics

```
npm create astro@latest -- --template basics
```

[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg/)](https://stackblitz.com/github/withastro/astro/tree/latest/examples/basics/)
[![Open with CodeSandbox](https://assets.codesandbox.io/github/button-edit-lime.svg/)](https://codesandbox.io/p/sandbox/github/withastro/astro/tree/latest/examples/basics/)
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg/)](https://codespaces.new/withastro/astro/?devcontainer_path=.devcontainer/basics/devcontainer.json)

> 🧑‍🚀 **Seasoned astronaut?** Delete this file. Have fun!

![just-the-basics](https://github.com/withastro/astro/assets/2244813/a0a5533c-a856-4198-8470-2d67b1d7c554/)

## 🚀 Project Structure

Inside of your Astro project, you'll see the following folders and files:
Expand Down Expand Up @@ -88,6 +74,28 @@ All commands are run from the root of the project, from a terminal:
| `bun run astro ...` | Run CLI commands like `astro add`, `astro check` |
| `bun run astro -- --help` | Get help using the Astro CLI |

## 👀 Want to learn more?
## Automatic i18n

The website aims at having an automatic i18n done via various scripts in the `scripts` directory.

The [translations.tsx](./scripts/translations.tsx) script is used to translate the website content into the desired language. It has two methods to create translations, via `OpenAI API`, and the other via `api.datpmt.com`. To use the OpenAI API method, make sure you have an `OPENAI_API_KEY` as the environment variable set. To use the other API, just un-comment the `translateText` function call using it.

Now, let's say that you want to update translations or add a new locale, `fr`.

First, make sure to update the files `scripts/setup_new_locale.tsx` and `scripts/generate_translation_ts_file.tsx` to have the latest locale values as the following respectively.

```tsx
const newLocale = 'fr'
```

```tsx
const locales = ['fr']
```

Now to have translations generated for `fr`, you'd want to run:

Feel free to check [our documentation](https://docs.astro.build/) or jump into our [Discord server](https://astro.build/chat/).
- `bun run setup:new:locale`: This script copies the existing files in `src/pages` directory to `src/pages/fr` directory and makes sure to replace each reference to `content/blog` to `content/fr/blog`. Then, it copies the `src/content/blog` directory to `src/content/fr/blog` and makes sure to set `locale` frontmatter in each markdown file as `fr`. Then, it runs all the translation scripts mentioned below.
- `bun run generate:locale:translations`: This script uses the translate function to translate the `en.yml` key value pairs into the desired language, and creates a `fr.yml` file.
- `bun run generate:translation.ts`: This script uses all the `.yml` files in the `locales` directory to generate two files, `src/services/locale.ts` and `src/services/translation.ts` files with all the locales translations key value pair.
- `bun run generate:blog:translations`: This script uses all the `.md` files in the `src/content/blog` directory to generate the translated version of the file in the `src/content/fr/blog` directory.
- `bun run generate:plugin:translations`: This script uses all the `.md` files in the `src/content/plugins-tutorials` directory to generate the translated version of the file in the `src/content/fr/plugins-tutorials` directory.
1 change: 1 addition & 0 deletions _redirects
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ docs/plugin/know-issues docs/plugin/known-issues/ 200
/self-hosted-capgo /docs/plugin/self-hosted/getting-started/ 200
/self-hosted-live-updates /docs/plugin/self-hosted/auto-update/ 200
/docs/getting-started/ /docs/plugin/cloud-mode/getting-started/ 302
/sitemap.xml /sitemap-index.xml 301
/sitemap-index.xml/ /sitemap-index.xml 301
/sitemap-0.xml/ /sitemap-0.xml 301
54 changes: 40 additions & 14 deletions astro.config.mjs
Original file line number Diff line number Diff line change
@@ -1,20 +1,33 @@
import starlight from '@astrojs/starlight'
import vue from '@astrojs/vue'
import UnoCSS from '@unocss/astro'
import AstroPWA from '@vite-pwa/astro'
import starlight from '@astrojs/starlight'
import { defineConfig } from 'astro/config'
import { pwa } from './src/config/pwa'
import config from './configs.json'
import { pwa } from './src/config/pwa'
import { defaultLocale, locales } from './src/services/locale'

export default defineConfig({
compressHTML: true,
site: `https://${config.base_domain.prod}`,
redirects: {
'/docs/getting-started/': {
status: 302,
destination: '/docs/plugin/cloud-mode/getting-started/',
},
},
i18n: {
locales,
defaultLocale,
fallback: locales
.filter((i) => i !== defaultLocale)
.reduce((r, h) => {
r[h] = defaultLocale
return r
}, {}),
routing: {
redirectToDefaultLocale: true,
},
},
integrations: [
UnoCSS({ injectReset: true }),
vue({
Expand All @@ -29,10 +42,13 @@ export default defineConfig({
title: 'Capgo',
favicon: '/favicon.svg',
logo: { src: './logo.svg' },
editLink: {
baseUrl: 'https://github.com/Cap-go/website/edit/main/',
},
customCss: ['./src/css/global.css'],
components: {
LanguageSelect: './src/components/LanguageSelect.astro',
},
editLink: {
baseUrl: 'https://github.com/Cap-go/website/edit/main/',
},
social: {
discord: 'https://discord.com/invite/VnYRvBfgA6',
github: 'https://github.com/Cap-go/',
Expand All @@ -54,7 +70,8 @@ export default defineConfig({
label: 'Plugin',
items: [
{ label: 'Overview', link: '/docs/plugin/overview' },
{ label: 'Cloud Mode',
{
label: 'Cloud Mode',
items: [
{ label: 'Getting Started', link: '/docs/plugin/cloud-mode/getting-started' },
{ label: 'Auto Update', link: '/docs/plugin/cloud-mode/auto-update' },
Expand All @@ -65,15 +82,16 @@ export default defineConfig({
collapsed: true,
},
{
label: 'Self Hosted', items: [
label: 'Self Hosted',
items: [
{ label: 'Getting Started', link: '/docs/plugin/self-hosted/getting-started' },
{ label: 'Contributing', link: '/docs/plugin/self-hosted/contributing' },
{ label: 'Auto Update', link: '/docs/plugin/self-hosted/auto-update' },
{ label: 'Manual Update', link: '/docs/plugin/self-hosted/manual-update' },
{ label: 'Encrypted Bundles', link: '/docs/plugin/self-hosted/encrypted-bundles' },
{ label: 'Handling Updates', link: '/docs/plugin/self-hosted/handling-updates' },
{ label: 'Handling Stats', link: '/docs/plugin/self-hosted/handling-stats' },
{ label: 'Local Development', autogenerate: { directory: 'docs/plugin/self-hosted/local-dev' }, collapsed: true}
{ label: 'Local Development', autogenerate: { directory: 'docs/plugin/self-hosted/local-dev' }, collapsed: true },
],
collapsed: true,
},
Expand All @@ -88,7 +106,7 @@ export default defineConfig({
collapsed: true,
autogenerate: { directory: 'docs/upgrade' },
},
]
],
},
{
label: 'CLI',
Expand All @@ -100,14 +118,12 @@ export default defineConfig({
collapsed: true,
autogenerate: { directory: 'docs/cli/migrations' },
},
]
],
},
{
label: 'Public API',
collapsed: true,
items: [
{ label: 'Endpoints', link: '/docs/public-api/endpoints' },
]
items: [{ label: 'Endpoints', link: '/docs/public-api/endpoints' }],
},
{
label: 'Web app',
Expand All @@ -134,4 +150,14 @@ export default defineConfig({
],
}),
],
server: {
port: 3000,
open: true,
host: '0.0.0.0',
},
preview: {
port: 3000,
open: true,
host: '0.0.0.0',
},
})
Binary file modified bun.lockb
Binary file not shown.
Loading
Loading