-
-
Notifications
You must be signed in to change notification settings - Fork 376
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. new translation docs 2. lazy-load TimeAgo locales (used for "x min ago" messages). This 1. reduces size and 2. provides all languages without adding them manually. 3. Remove DayJS locales, they're unused.
- Loading branch information
Showing
10 changed files
with
67 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,9 @@ | ||
# Translations | ||
|
||
Woodpecker uses [Vue I18n](https://vue-i18n.intlify.dev/) as translation library, thus you can easily translate the web UI into your language. Therefore, copy the file `web/src/assets/locales/en.json` to the same path with your language's code and `.json` as name. | ||
Then, translate content of this file, but only the values: | ||
To translate the web UI into your language, we have [our own Weblate instance](https://translate.woodpecker-ci.org/). Please register there and translate Woodpecker into your language. **We won't accept PRs changing any language except English.** | ||
|
||
```json | ||
{ | ||
"dont_translate": "Only translate this text" | ||
} | ||
``` | ||
<a href="https://translate.woodpecker-ci.org/engage/woodpecker-ci/"> | ||
<img src="https://translate.woodpecker-ci.org/widgets/woodpecker-ci/-/ui/multi-blue.svg" alt="Translation status" /> | ||
</a> | ||
|
||
To add support for time formatting, import the language into two files: | ||
|
||
1. `web/src/compositions/useDate.ts`: Just add a line like `import 'dayjs/locale/en';` to the first block of `import` statements and replace `en` with your language's code. | ||
2. `web/src/utils/timeAgo.ts`: Add a line like `import en from 'javascript-time-ago/locale/en.json';` to the other `import`-statements and replace both `en`s with your language's code. Then, add the line `TimeAgo.addDefaultLocale(en);` to the other lines of them, and replace `en` with your language's code. | ||
|
||
Then, the web UI should be available in your language. You should open a pull request to our repository to get your changes into the next release. | ||
Woodpecker uses [Vue I18n](https://vue-i18n.intlify.dev/) as translation library. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ node_modules | |
dist | ||
dist-ssr | ||
*.local | ||
src/assets/timeAgoLocales |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import TimeAgo from 'javascript-time-ago'; | ||
import en from 'javascript-time-ago/locale/en.json'; | ||
|
||
import { getUserLanguage } from '~/utils/locale'; | ||
|
||
TimeAgo.addDefaultLocale(en); | ||
|
||
const addedLocales = ['en']; | ||
|
||
export default () => new TimeAgo(getUserLanguage()); | ||
export async function loadTimeAgoLocale(locale: string) { | ||
if (!addedLocales.includes(locale)) { | ||
const { default: timeAgoLocale } = await import(`~/assets/timeAgoLocales/${locale}.js`); | ||
TimeAgo.addLocale(timeAgoLocale); | ||
addedLocales.push(locale); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters