Skip to content

Commit

Permalink
Merge branch 'main' into patch-0103
Browse files Browse the repository at this point in the history
  • Loading branch information
delucis authored Jan 4, 2024
2 parents bc456e1 + 5ff926f commit 2cd87a2
Show file tree
Hide file tree
Showing 42 changed files with 843 additions and 110 deletions.
5 changes: 5 additions & 0 deletions .changeset/afraid-horses-compare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@astrojs/starlight": patch
---

chore: fix type errors in Starlight internals
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
2 changes: 1 addition & 1 deletion docs-i18n-tracker/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const translationStatusBuilder = new TranslationStatusBuilder({
htmlOutputFilePath: './dist/index.html',
sourceLanguage: 'en',
targetLanguages: Object.values(locales)
.reduce((acc, { lang }) => (lang !== 'en' ? [lang, ...acc] : acc), [])
.reduce((acc, { lang }) => (lang !== 'en' ? [lang, ...acc] : acc), new Array<string>())
.sort(),
languageLabels: Object.values(locales)
.filter((loc) => loc.lang !== 'en')
Expand Down
1 change: 1 addition & 0 deletions docs-i18n-tracker/lib/github-get.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import pRetry, { AbortError } from 'p-retry';
export async function githubGet({ url, githubToken = undefined }) {
return await pRetry(
async () => {
/** @type {Record<string, string>} */
const headers = {
Accept: 'application/vnd.github.v3+json',
};
Expand Down
5 changes: 3 additions & 2 deletions docs-i18n-tracker/lib/output.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export function error(message, ...params) {
/**
* Dedents the given markdown and replaces single newlines with spaces,
* while leaving new paragraphs intact.
* @param {[string | TemplateStringsArray, ...any[]]} markdown
*/
export function dedentMd(...markdown) {
return dedent(...markdown).replace(/(\S)\n(?!\n)/g, '$1 ');
Expand All @@ -56,7 +57,7 @@ export function formatCount(count, template) {
const wrapWithCount = (text) => {
// If no count was given, we're outputting a single issue in annotations,
// so omit count and capitalize the first letter of the issue type description
if (count === undefined) return text[0].toUpperCase() + text.slice(1);
if (count === undefined) return text[0]?.toUpperCase() + text.slice(1);

// Otherwise, prefix the issue type description with count
return `${count} ${text}`;
Expand All @@ -65,7 +66,7 @@ export function formatCount(count, template) {
const usePlural = count !== undefined && count !== 1;
const templateParts = template.split('|');
const usedTemplate = templateParts.length === 2 ? templateParts[usePlural ? 1 : 0] : template;
return wrapWithCount(usedTemplate.replace(/\(s\)/g, usePlural ? 's' : ''));
return wrapWithCount(usedTemplate?.replace(/\(s\)/g, usePlural ? 's' : '') ?? '');
}

export default {
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"
}
18 changes: 18 additions & 0 deletions docs/lunaria/components.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
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
4 changes: 2 additions & 2 deletions docs/src/components/theme-designer.astro
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
import { TabItem, Tabs } from '@astrojs/starlight/components';
import ColorEditor, { Props as EditorProps } from './theme-designer/color-editor.astro';
import Presets, { Props as PresetsProps } from './theme-designer/presets.astro';
import ColorEditor, { type Props as EditorProps } from './theme-designer/color-editor.astro';
import Presets, { type Props as PresetsProps } from './theme-designer/presets.astro';
import Preview from './theme-designer/preview.astro';
interface Props {
Expand Down
10 changes: 7 additions & 3 deletions docs/src/content/docs/de/guides/i18n.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,13 @@ Du kannst Übersetzungen für zusätzliche Sprachen, die du unterstützt, über
"i18n.untranslatedContent": "This content is not available in your language yet.",
"page.editLink": "Edit page",
"page.lastUpdated": "Last updated:",
"page.previousLink": "Next",
"page.nextLink": "Previous",
"404.text": "Page not found. Check the URL or try using the search bar."
"page.previousLink": "Previous",
"page.nextLink": "Next",
"404.text": "Page not found. Check the URL or try using the search bar.",
"aside.note": "Note",
"aside.tip": "Tip",
"aside.caution": "Caution",
"aside.danger": "Danger"
}
```

Expand Down
10 changes: 7 additions & 3 deletions docs/src/content/docs/es/guides/i18n.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,13 @@ Puedes proprocionar traducciones para idiomas adicionales, o editar nuestras eti
"i18n.untranslatedContent": "This content is not available in your language yet.",
"page.editLink": "Edit page",
"page.lastUpdated": "Last updated:",
"page.previousLink": "Next",
"page.nextLink": "Previous",
"404.text": "Page not found. Check the URL or try using the search bar."
"page.previousLink": "Previous",
"page.nextLink": "Next",
"404.text": "Page not found. Check the URL or try using the search bar.",
"aside.note": "Note",
"aside.tip": "Tip",
"aside.caution": "Caution",
"aside.danger": "Danger"
}
```

Expand Down
10 changes: 7 additions & 3 deletions docs/src/content/docs/fr/guides/i18n.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,13 @@ Vous pouvez fournir des traductions pour les langues supplémentaires que vous s
"i18n.untranslatedContent": "This content is not available in your language yet.",
"page.editLink": "Edit page",
"page.lastUpdated": "Last updated:",
"page.previousLink": "Next",
"page.nextLink": "Previous",
"404.text": "Page not found. Check the URL or try using the search bar."
"page.previousLink": "Previous",
"page.nextLink": "Next",
"404.text": "Page not found. Check the URL or try using the search bar.",
"aside.note": "Note",
"aside.tip": "Tip",
"aside.caution": "Caution",
"aside.danger": "Danger"
}
```

Expand Down
10 changes: 7 additions & 3 deletions docs/src/content/docs/guides/i18n.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,13 @@ You can provide translations for additional languages you support — or overrid
"i18n.untranslatedContent": "This content is not available in your language yet.",
"page.editLink": "Edit page",
"page.lastUpdated": "Last updated:",
"page.previousLink": "Next",
"page.nextLink": "Previous",
"404.text": "Page not found. Check the URL or try using the search bar."
"page.previousLink": "Previous",
"page.nextLink": "Next",
"404.text": "Page not found. Check the URL or try using the search bar.",
"aside.note": "Note",
"aside.tip": "Tip",
"aside.caution": "Caution",
"aside.danger": "Danger"
}
```

Expand Down
Loading

0 comments on commit 2cd87a2

Please sign in to comment.