Skip to content

Commit

Permalink
Migrate localization tooling to Lunaria (#1310)
Browse files Browse the repository at this point in the history
Co-authored-by: Chris Swithinbank <[email protected]>
  • Loading branch information
yanthomasdev and delucis authored Jan 4, 2024
1 parent 197b0e1 commit f257f5f
Show file tree
Hide file tree
Showing 7 changed files with 391 additions and 10 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ Visit **<https://i18n.starlight.astro.build>** to track translation progress for
To add a language, you will need its BCP-47 tag and a label. See [“Adding a new language”](https://github.com/withastro/docs/blob/main/contributor-guides/translating-astro-docs.md#adding-a-new-language) in the Astro docs repo for some helpful tips around choosing these.

- Add your language to the `locales` config in `docs/astro.config.mjs`
- Add your language to the `locales` config in `docs/lunaria.config.json`
- Add your language’s subtag to the i18n label config in `.github/labeler.yml`
- Add your language to the `pa11y` script’s `--sitemap-exclude` flag in `package.json`
- Create the first translated page for your language.
Expand Down
98 changes: 98 additions & 0 deletions docs/lunaria.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
{
"$schema": "./node_modules/@lunariajs/core/config.schema.json",
"repository": {
"name": "withastro/starlight",
"rootDir": "docs"
},
"defaultLocale": {
"label": "English",
"lang": "en"
},
"locales": [
{
"label": "Dansk",
"lang": "da"
},
{
"label": "Deutsch",
"lang": "de"
},
{
"label": "Español",
"lang": "es"
},
{
"label": "Français",
"lang": "fr"
},
{
"label": "हिंदी",
"lang": "hi"
},
{
"label": "Bahasa Indonesia",
"lang": "id"
},
{
"label": "Italiano",
"lang": "it"
},
{
"label": "日本語",
"lang": "ja"
},
{
"label": "한국어",
"lang": "ko"
},
{
"label": "Português do Brasil",
"lang": "pt-br"
},
{
"label": "Русский",
"lang": "ru"
},
{
"label": "Türkçe",
"lang": "tr"
},
{
"label": "Українська",
"lang": "uk"
},
{
"label": "简体中文",
"lang": "zh-cn"
}
],
"files": [
{
"location": "src/content/docs/**/*.{md,mdx}",
"pattern": "src/content/docs/@lang/@path"
}
],
"dashboard": {
"title": "Starlight Docs Translation Status",
"description": "Translation progress tracker for the Starlight Docs site. See how much has been translated in your language and get involved!",
"favicon": {
"external": [
{
"link": "https://starlight.astro.build/favicon.svg",
"type": "image/svg+xml"
}
]
},
"customCss": ["./lunaria/styles.css"],
"basesToHide": ["src/content/docs/"],
"ui": {
"statusByLocale.heading": "Translation progress by locale",
"statusByLocale.incompleteLocalizationLink": "incomplete translation",
"statusByLocale.outdatedLocalizationLink": "outdated translation",
"statusByLocale.completeLocalization": "This translation is complete, amazing job! 🎉",
"statusByFile.heading": "Translation status by file"
}
},
"ignoreKeywords": ["lunaria-ignore", "typo", "en-only", "broken link", "i18nReady", "i18nIgnore"],
"renderer": "./lunaria/renderer.config.ts"
}
15 changes: 15 additions & 0 deletions docs/lunaria/components.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { html } from '@lunariajs/core';

export const TitleParagraph = () => html`
<p>
If you're interested in helping us translate
<a href="https://starlight.astro.build/">starlight.astro.build</a> into one of the languages
listed below, you've come to the right place! This auto-updating page always lists all the
content that could use your help right now.
</p>
<p>
Before starting a new translation, please read our
<a href="https://github.com/withastro/starlight/blob/main/CONTRIBUTING.md#translating-starlights-docs">translation guide</a>
to learn about our translation process and how you can get involved.
</p>
`;
8 changes: 8 additions & 0 deletions docs/lunaria/renderer.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { defineRendererConfig } from '@lunariajs/core';
import { TitleParagraph } from './components';

export default defineRendererConfig({
slots: {
afterTitle: TitleParagraph,
},
});
47 changes: 47 additions & 0 deletions docs/lunaria/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
:root {
--theme-accent: hsl(234, 100%, 87%);
--theme-bg: hsl(223, 13%, 10%);
--theme-table-header: hsl(222, 13%, 16%);
--theme-table-hover: hsl(222, 13%, 16%);
--theme-text: hsl(228, 8%, 77%);
--theme-text-bright: hsl(0, 0%, 100%);
--overlay-blurple: hsla(255, 60%, 60%, 0.2);

--ln-color-background: linear-gradient(215deg, var(--overlay-blurple), transparent 40%),
radial-gradient(var(--overlay-blurple), transparent 40%) no-repeat -60vw -40vh / 105vw 200vh,
radial-gradient(var(--overlay-blurple), transparent 65%) no-repeat 50% calc(100% + 20rem) /
60rem 30rem,
var(--theme-bg);
--ln-color-link: var(--theme-accent);
--ln-color-black: var(--theme-text);
--ln-color-done: var(--ln-color-blue);
--ln-color-outdated: #ea580c;
--ln-color-missing: var(--theme-text-bright);
--ln-color-table-background: var(--theme-table-header);
--ln-color-table-border: var(--theme-table-header);

color-scheme: dark;
}

h1,
h2,
h3,
h4,
h5,
h6 {
color: var(--theme-text-bright);
}

p a {
text-decoration: underline;
}

.create-button {
background-color: hsl(213deg 89% 64% / 20%);
border-radius: 0.5em;
}

sup {
display: flex;
justify-content: center;
}
4 changes: 3 additions & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
"start": "astro dev",
"build": "astro build",
"preview": "astro preview",
"astro": "astro"
"astro": "astro",
"lunaria:build": "lunaria build"
},
"dependencies": {
"@astrojs/starlight": "workspace:*",
"@lunariajs/core": "^0.0.25",
"@types/culori": "^2.0.0",
"astro": "^4.0.1",
"culori": "^3.2.0",
Expand Down
Loading

0 comments on commit f257f5f

Please sign in to comment.