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

Update from main #623

Merged
merged 242 commits into from
Aug 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
242 commits
Select commit Hold shift + click to select a range
c2e6d73
Initial i18n dev
cheeaun Aug 13, 2024
e58f592
Update Crowdin configuration file
cheeaun Aug 13, 2024
4918027
Use real ellipsis
cheeaun Aug 13, 2024
2c050c6
Fix wrong pluralization usage
cheeaun Aug 14, 2024
c311622
Seems like 'es' is not needed now, weird
cheeaun Aug 14, 2024
b28fdcb
Fix wrong passing of locale values in Intl.DisplayNames
cheeaun Aug 14, 2024
2ab921d
Load `en` by default, activate it later
cheeaun Aug 14, 2024
30a2a6a
Add Crowdin PR label and custom commit message
cheeaun Aug 14, 2024
d1887af
The lines have changed
cheeaun Aug 14, 2024
9219432
Try limit export language
cheeaun Aug 14, 2024
868e613
Use msg here because the memo'ed Home doesn't re-render
cheeaun Aug 14, 2024
3048bd1
Switch the common/native text
cheeaun Aug 14, 2024
d9bc18f
Oops, accidentally add this locale when it's not ready yet
cheeaun Aug 14, 2024
e581568
Add try/catch fallback if file fails to load
cheeaun Aug 14, 2024
6d15dfb
Upgrade dependencies
cheeaun Aug 14, 2024
fcb85d1
lol %locale% doesn't work for this
cheeaun Aug 14, 2024
f359d36
Sync the list of locales between config & app code
cheeaun Aug 14, 2024
b1a8f1a
Build locales into separate folder
cheeaun Aug 14, 2024
59f8f44
Use v2 notifications policy API and new UI
cheeaun Aug 14, 2024
6cc96b8
Default to extract + clean + watch
cheeaun Aug 14, 2024
b16907d
Forgot to localise these keyboard shortcuts
cheeaun Aug 14, 2024
f9b6768
Prevent text blocks from wrapping
cheeaun Aug 14, 2024
ac94303
Fix horizontal menu control group placement bug
cheeaun Aug 14, 2024
377ad11
Fix relative time ago exceeding 24 hours
cheeaun Aug 15, 2024
ad0cb12
Try this crowdin setting to skip untranslated files/strings
cheeaun Aug 15, 2024
acba051
Another attempt for Crowdin
cheeaun Aug 15, 2024
1a3751f
Forgot to set lang attr on html
cheeaun Aug 15, 2024
503d0a9
New translations (Chinese Simplified)
cheeaun Aug 15, 2024
b351060
Make lang selector smaller
cheeaun Aug 15, 2024
89a2e7d
Fix wrong feature detection for trending link posts
cheeaun Aug 15, 2024
bdb1dff
Fix this unneeded Plural
cheeaun Aug 16, 2024
6c0f0a4
More fallbacks for Intl.DisplayNames
cheeaun Aug 16, 2024
c914cf5
Don't even need dayjs anymore
cheeaun Aug 16, 2024
05f488c
Replace npm-run-all2 with vite-plugin-run
cheeaun Aug 16, 2024
0d990b6
New translations (Chinese Simplified)
cheeaun Aug 16, 2024
8ec951d
These menus need spans
cheeaun Aug 16, 2024
baed9dd
New translations (Chinese Simplified)
cheeaun Aug 16, 2024
c96ff42
New translations (Chinese Simplified)
cheeaun Aug 16, 2024
6d68232
Make lang selector fixed-width
cheeaun Aug 16, 2024
18b3ee8
Standardize display of common + native languages list
cheeaun Aug 16, 2024
9d59530
Let in the first 5 most-translated languages for testing
cheeaun Aug 16, 2024
6b27fe6
New translations (Spanish)
cheeaun Aug 16, 2024
38c00ef
New translations (Chinese Simplified)
cheeaun Aug 16, 2024
0c92774
New translations (Chinese Simplified)
cheeaun Aug 16, 2024
eb24b9a
New translations (Spanish)
cheeaun Aug 16, 2024
07c4be5
Add another language
cheeaun Aug 17, 2024
57f245d
Remove export_languages
cheeaun Aug 17, 2024
ebcd7d1
New translations (French)
cheeaun Aug 17, 2024
8da8c55
New translations (Arabic)
cheeaun Aug 17, 2024
a1885d1
New translations (Catalan)
cheeaun Aug 17, 2024
c19e423
New translations (German)
cheeaun Aug 17, 2024
dfa6c2e
New translations (Basque)
cheeaun Aug 17, 2024
913e9ce
New translations (Finnish)
cheeaun Aug 17, 2024
4e9a0d6
New translations (Italian)
cheeaun Aug 17, 2024
f05fc55
New translations (Japanese)
cheeaun Aug 17, 2024
a7f2cd5
New translations (Korean)
cheeaun Aug 17, 2024
760588c
New translations (Dutch)
cheeaun Aug 17, 2024
ea12b8f
New translations (Chinese Traditional)
cheeaun Aug 17, 2024
8919aee
New translations (Galician)
cheeaun Aug 17, 2024
eff4381
New translations (Occitan)
cheeaun Aug 17, 2024
3236aac
New translations (Kabyle)
cheeaun Aug 17, 2024
915c8f5
New translations (Hebrew)
cheeaun Aug 17, 2024
72d9017
New translations (Portuguese)
cheeaun Aug 17, 2024
6b9a9e7
New translations (Persian)
cheeaun Aug 17, 2024
ab1babf
New translations (Esperanto)
cheeaun Aug 17, 2024
81e956a
New translations (Czech)
cheeaun Aug 17, 2024
fdc303f
New translations (Lithuanian)
cheeaun Aug 17, 2024
720603b
New translations (Russian)
cheeaun Aug 17, 2024
fbfe321
New translations (Thai)
cheeaun Aug 17, 2024
8bd5648
Merge pull request #628 from cheeaun/l10n_main
cheeaun Aug 17, 2024
dd772c1
Handle the list here
cheeaun Aug 17, 2024
70aef68
Prevent language select from breaking in Settings
cheeaun Aug 17, 2024
139bcfe
Only extract en
cheeaun Aug 17, 2024
568c4a2
fetch-instances doesn't need .env.local
cheeaun Aug 17, 2024
d38e3e7
Update instances list
cheeaun Aug 17, 2024
88c14e9
Fix nav menu messed up in German
cheeaun Aug 17, 2024
96cab91
New Crowdin updates (#630)
cheeaun Aug 18, 2024
5e2d084
Fix lang selector not centered on Welcome page
cheeaun Aug 17, 2024
15e4012
Fix carousel not scrolling
cheeaun Aug 18, 2024
1fde4c6
Less-noisy language selector with perhaps better sort
cheeaun Aug 18, 2024
0f41d46
Add new languages: Catalan, French, Korean
cheeaun Aug 18, 2024
480e1aa
Should use localeCompare
cheeaun Aug 18, 2024
3207461
Test i18n PR automation
cheeaun Aug 18, 2024
d8e6342
Allow manual dispatch
cheeaun Aug 18, 2024
d09eb13
New Crowdin updates (#631)
cheeaun Aug 18, 2024
773aa9d
Oops, need to handle more cases and debug
cheeaun Aug 18, 2024
cf623d4
Try again
cheeaun Aug 18, 2024
ebf400b
New Crowdin updates (#632)
cheeaun Aug 18, 2024
1cb8fdb
New Crowdin updates (#633)
cheeaun Aug 18, 2024
f83b97b
New Crowdin updates (#634)
cheeaun Aug 18, 2024
ab54e98
Change to 50
cheeaun Aug 18, 2024
6aed637
Prevent concurrent runs
cheeaun Aug 18, 2024
82bb7e1
New Crowdin updates (#635)
cheeaun Aug 18, 2024
031d021
New Crowdin updates (#636)
cheeaun Aug 18, 2024
a4cc0fb
New Crowdin updates (#638)
cheeaun Aug 18, 2024
7cc44e5
New Crowdin updates (#639)
cheeaun Aug 18, 2024
a12006b
New Crowdin updates (#640)
cheeaun Aug 18, 2024
96e4a3d
New translations (Catalan) (#641)
cheeaun Aug 19, 2024
b286511
Fix PHANPY_DEFAULT_LANG not working
cheeaun Aug 19, 2024
8c02d33
Auto-generate list of catalogs from PO files
cheeaun Aug 19, 2024
6e59faa
Test update catalogs.json while auto-merging i18n PRs
cheeaun Aug 19, 2024
86bfde0
Less noisy action
cheeaun Aug 19, 2024
666d9b7
This needs node
cheeaun Aug 19, 2024
e736617
Fix bidi for handle in header
cheeaun Aug 19, 2024
6f8ed84
This needs identity
cheeaun Aug 19, 2024
6fe922d
Revert "Fix PHANPY_DEFAULT_LANG not working"
cheeaun Aug 19, 2024
8a2150d
All handles need bidi isolate
cheeaun Aug 19, 2024
f291d33
Fix push error hopefully
cheeaun Aug 19, 2024
876480f
Split the workflows
cheeaun Aug 19, 2024
f3f18e7
New Crowdin updates (#643)
cheeaun Aug 19, 2024
3893330
Update catalogs.json
github-actions[bot] Aug 19, 2024
4278826
Probably need this event to trigger
cheeaun Aug 19, 2024
a583332
New Crowdin updates (#644)
cheeaun Aug 19, 2024
ff06b92
New Crowdin updates (#645)
cheeaun Aug 19, 2024
0963782
New Crowdin updates (#646)
cheeaun Aug 19, 2024
98febe5
Try fix workflow event not working
cheeaun Aug 20, 2024
b9a56c4
New Crowdin updates (#647)
cheeaun Aug 20, 2024
cc8dbeb
Try these again
cheeaun Aug 20, 2024
0bc7b62
Revise the sentence to be clearer
cheeaun Aug 20, 2024
e612fc1
New translations (Finnish) (#648)
cheeaun Aug 20, 2024
b5fe61a
Update catalogs.json
github-actions[bot] Aug 20, 2024
fd7c924
Make workflow run more specifically
cheeaun Aug 20, 2024
7c8c0ce
New Crowdin updates (#649)
cheeaun Aug 20, 2024
a4347e9
New Crowdin updates (#650)
cheeaun Aug 20, 2024
0404c6e
New translations (Kabyle) (#651)
cheeaun Aug 20, 2024
5bf81b2
New translations (Kabyle) (#652)
cheeaun Aug 20, 2024
2db909d
Try/catch all intl stuff
cheeaun Aug 20, 2024
3902db5
Handle kab issue temporarily
cheeaun Aug 20, 2024
0e539ba
Require additional info if report account
cheeaun Aug 20, 2024
3b15768
Handle kab-KAB → kab rename
cheeaun Aug 20, 2024
bcf8a9c
Remove cancel-in-progress, it's too noisy
cheeaun Aug 20, 2024
0dbc76c
Fix my dumb code
cheeaun Aug 20, 2024
01d6bda
New Crowdin updates (#653)
cheeaun Aug 20, 2024
ce50b7a
New Crowdin updates (#654)
cheeaun Aug 20, 2024
79d4330
Set max width for the filter badge
cheeaun Aug 20, 2024
883e323
Try pull_request_target instead
cheeaun Aug 20, 2024
f56943a
Try exit silently
cheeaun Aug 20, 2024
a246c89
Why this ain't running
cheeaun Aug 20, 2024
4e5cb13
New Crowdin updates (#655)
cheeaun Aug 20, 2024
32e1974
New Crowdin updates (#658)
cheeaun Aug 20, 2024
2ec5bf0
New Crowdin updates (#659)
cheeaun Aug 20, 2024
dbddd90
Revert back to previous event setting
cheeaun Aug 21, 2024
2b1fa6a
Limit this to l10n_main branch
cheeaun Aug 21, 2024
056e22a
Split context for two "Post" strings
cheeaun Aug 21, 2024
d9c12aa
Try add sourceLocale
cheeaun Aug 21, 2024
241f7f8
lol this srsly doesn't run
cheeaun Aug 21, 2024
0ec5afc
New Crowdin updates (#660)
cheeaun Aug 21, 2024
ae47183
Update catalogs.json
github-actions[bot] Aug 21, 2024
e073756
New Crowdin updates (#662)
cheeaun Aug 21, 2024
ca53672
Update catalogs
cheeaun Aug 21, 2024
c542286
Move this to run locally instead of Actions
cheeaun Aug 21, 2024
cea06f3
Make sure nice-date-time also match the more local locale
cheeaun Aug 21, 2024
25d73c4
Show all locales, <50% complete will be called devLocales
cheeaun Aug 21, 2024
c7ad441
New Crowdin updates (#663)
cheeaun Aug 21, 2024
708738d
New Crowdin updates (#664)
cheeaun Aug 21, 2024
8c1e1d9
New Crowdin updates (#665)
cheeaun Aug 21, 2024
d54cb61
Update catalogs
cheeaun Aug 22, 2024
36f0e7a
Increase line height for menu items
cheeaun Aug 22, 2024
9b2c01f
Fix locale matching
cheeaun Aug 22, 2024
2ea2bf6
New Crowdin updates (#666)
cheeaun Aug 22, 2024
b5f6e60
Upgrade dependencies
cheeaun Aug 22, 2024
93ccf47
New translations (Italian) (#668)
cheeaun Aug 22, 2024
9995503
New Crowdin updates (#669)
cheeaun Aug 22, 2024
6067602
New Crowdin updates (#670)
cheeaun Aug 23, 2024
54d1fdc
Remove console.log
cheeaun Aug 23, 2024
e5f674c
Add link to Crowdin
cheeaun Aug 23, 2024
482d8c3
Better locale matching
cheeaun Aug 23, 2024
67bbbfb
Update en.po
cheeaun Aug 23, 2024
fcb2899
Update catalogs
cheeaun Aug 23, 2024
6528122
New Crowdin updates (#671)
cheeaun Aug 23, 2024
e2bf235
New Crowdin updates (#672)
cheeaun Aug 24, 2024
8ac14d1
New Crowdin updates (#673)
cheeaun Aug 24, 2024
1bfe3f5
Fix text flowed out of card
cheeaun Aug 23, 2024
b2fa32d
Generate alternate link tags for all languages
cheeaun Aug 24, 2024
ea53d8a
Attempt to make menus wider
cheeaun Aug 24, 2024
714fcb4
Add switch menus for Accounts
cheeaun Aug 24, 2024
afa47da
Check log-in state for Composer page
cheeaun Aug 24, 2024
2fa40e8
Update en
cheeaun Aug 24, 2024
bb75f42
Sort deterministically for less-noisy diffs
cheeaun Aug 24, 2024
f9f573a
Update catalogs
cheeaun Aug 24, 2024
a29c17a
New Crowdin updates (#675)
cheeaun Aug 24, 2024
26bf546
New Crowdin updates (#676)
cheeaun Aug 24, 2024
1b93325
New Crowdin updates (#677)
cheeaun Aug 24, 2024
1e23b09
New Crowdin updates (#678)
cheeaun Aug 24, 2024
0bbb631
New translations (Portuguese) (#679)
cheeaun Aug 24, 2024
5d2f8ff
Use secure same-site session cookie instead of sessionStorage
cheeaun Aug 25, 2024
e2eeffd
Update catalogs
cheeaun Aug 25, 2024
58ccdf8
Try fix the menu width again
cheeaun Aug 25, 2024
75853cd
New Crowdin updates (#680)
cheeaun Aug 25, 2024
c3eb33e
Only show Switch menu items when more than 1 account
cheeaun Aug 25, 2024
fe5ec91
Use store
cheeaun Aug 25, 2024
6f7e761
Update en
cheeaun Aug 25, 2024
6263c01
Update catalogs
cheeaun Aug 25, 2024
44b17c2
New Crowdin updates (#681)
cheeaun Aug 25, 2024
7b22b32
New Crowdin updates (#682)
cheeaun Aug 25, 2024
46f03c4
Try update catalogs workflow again
cheeaun Aug 25, 2024
8be26d9
New translations (Portuguese) (#684)
cheeaun Aug 25, 2024
1ea903e
Make it fail silently
cheeaun Aug 25, 2024
f7a97c6
New Crowdin updates (#685)
cheeaun Aug 25, 2024
3c10b79
New translations (Portuguese) (#686)
cheeaun Aug 25, 2024
1bc1e57
New translations (Portuguese) (#687)
cheeaun Aug 25, 2024
572d778
Try to "debounce" this automerge workflow
cheeaun Aug 26, 2024
ef550fc
New Crowdin updates (#688)
cheeaun Aug 26, 2024
df8c64f
New Crowdin updates (#689)
cheeaun Aug 26, 2024
2bf1130
New Crowdin updates (#690)
cheeaun Aug 26, 2024
af29315
New Crowdin updates (#691)
cheeaun Aug 26, 2024
51e3341
New Crowdin updates (#692)
cheeaun Aug 26, 2024
1d69a1d
Get vapid key to instance config
cheeaun Aug 26, 2024
2e6074d
Disable this for now
cheeaun Aug 27, 2024
7c56b64
OAuth PKCE is in.
cheeaun Aug 27, 2024
ef0d9cd
New Crowdin updates (#693)
cheeaun Aug 27, 2024
6930ce9
Debounce page visibility to prevent streaming/polling noise
cheeaun Aug 27, 2024
3b0ca94
New Crowdin updates (#694)
cheeaun Aug 27, 2024
a88aaac
New Crowdin updates (#695)
cheeaun Aug 28, 2024
2e2ba24
New Crowdin updates (#697)
cheeaun Aug 29, 2024
50a2fe1
Trying out new hover style for top nav bar
cheeaun Aug 28, 2024
41af07c
Test show error toast if first load + no items
cheeaun Aug 29, 2024
f3895d0
Fix radio inputs intercept arrow keys
cheeaun Aug 29, 2024
a75e816
Try handle Threads' link
cheeaun Aug 29, 2024
7ff2411
Update en
cheeaun Aug 29, 2024
534e090
Subtle facelift for menus
cheeaun Aug 29, 2024
5646853
New Crowdin updates (#698)
cheeaun Aug 29, 2024
9cff1d0
New Crowdin updates (#699)
cheeaun Aug 29, 2024
c5553bc
New Crowdin updates (#700)
cheeaun Aug 30, 2024
c920030
New translations (Korean) (#701)
cheeaun Aug 30, 2024
c34ee3a
Fix filter badge text cropped off
cheeaun Aug 30, 2024
231a973
New Crowdin updates (#702)
cheeaun Aug 30, 2024
8dcb8f7
New Crowdin updates (#703)
cheeaun Aug 30, 2024
b4755f4
New Crowdin updates (#704)
cheeaun Aug 30, 2024
6faf380
New Crowdin updates (#705)
cheeaun Aug 30, 2024
471534f
New Crowdin updates (#706)
cheeaun Aug 30, 2024
32475dc
New Crowdin updates (#707)
cheeaun Aug 31, 2024
34b49f4
Upgrade vite-plugin-pwa
cheeaun Aug 30, 2024
c6beb79
Upgrade Valtio, things might break
cheeaun Aug 30, 2024
e910ac0
Better contrast in dark mode
cheeaun Aug 31, 2024
7c067a2
New translations (Galician) (#708)
cheeaun Aug 31, 2024
b013b43
Fix missing backgrounds for nav menu items
cheeaun Aug 31, 2024
ffab068
Show region for pt-BR
cheeaun Aug 31, 2024
4353a64
New translations (Spanish) (#709)
cheeaun Aug 31, 2024
550d1be
Fix missing showToast
cheeaun Aug 31, 2024
bff32b2
Fix toDataURL is not a function
cheeaun Aug 31, 2024
be4ef56
Update en
cheeaun Aug 31, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions .github/workflows/i18n-automerge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: i18n PR auto-merge

on:
pull_request:
types: [opened, synchronize, reopened, labeled]
branches:
- main

jobs:
run-and-merge:
if: contains(github.event.pull_request.labels.*.name, 'i18n') &&
github.event.pull_request.base.ref == 'main' &&
github.event.pull_request.head.ref == 'l10n_main'
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- run: sleep 15

- name: Check if the branch is dirty
run: |
git fetch origin ${{ github.event.pull_request.head.ref }}
if [ $(git rev-parse HEAD) != $(git rev-parse origin/${{ github.event.pull_request.head.ref }}) ]; then
echo "Branch is dirty. Exiting..."
exit 0
fi

- name: Check auto-merge conditions
run: |
BASE_SHA="${{ github.event.pull_request.base.sha }}"
HEAD_SHA="${{ github.event.pull_request.head.sha }}"

# Debug: Show the base and head SHA
echo "Base SHA: $BASE_SHA"
echo "Head SHA: $HEAD_SHA"

# Check if the commits exist
if ! git cat-file -e $BASE_SHA || ! git cat-file -e $HEAD_SHA; then
echo "ERROR: One or both of the commits are not available."
exit 1
fi

# Calculate the total number of lines changed (added, removed, or modified)
LINES_CHANGED=$(git diff --shortstat $BASE_SHA $HEAD_SHA | awk '{print $4 + $6 + $8}')

if [ -z "$LINES_CHANGED" ]; then
LINES_CHANGED=0
fi

echo "Total lines changed: $LINES_CHANGED"

# Check if the number of lines changed is more than 50
if [ "$LINES_CHANGED" -le 50 ]; then
exit 0
else
echo "More than 50 lines have been changed. Merging pull request."
PR_NUMBER=$(echo ${{ github.event.pull_request.number }})
gh pr merge $PR_NUMBER --auto --squash || true
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32 changes: 32 additions & 0 deletions .github/workflows/update-catalogs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Update Catalogs

on:
push:
branches:
- l10n_main
workflow_dispatch:

jobs:
update-catalogs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: l10n_main
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm ci
- name: Update catalogs.json
run: |
node scripts/catalogs.js
if git diff --quiet src/data/catalogs.json; then
echo "No changes to catalogs.json"
else
echo "Changes to catalogs.json"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
git add src/data/catalogs.json
git commit -m "Update catalogs.json"
git push origin HEAD:l10n_main || true
fi
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,7 @@ dist-ssr
# Custom
.env.dev
phanpy-dist.zip
phanpy-dist.tar.gz
phanpy-dist.tar.gz

# Compiled locale files
src/locales/*.js
61 changes: 60 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,12 @@ Everything is designed and engineered following my taste and vision. This is a p
Prerequisites: Node.js 18+

- `npm install` - Install dependencies
- `npm run dev` - Start development server
- `npm run dev` - Start development server and `messages:extract` (`clean` + ``watch`) in parallel
- `npm run build` - Build for production
- `npm run preview` - Preview the production build
- `npm run fetch-instances` - Fetch instances list from [joinmastodon.org/servers](https://joinmastodon.org/servers), save it to `src/data/instances.json`
- `npm run sourcemap` - Run `source-map-explorer` on the production build
- `npm run messages:extract` - Extract messages from source files and update the locale message catalogs

## Tech stack

Expand All @@ -115,10 +116,65 @@ Prerequisites: Node.js 18+
- [masto.js](https://github.com/neet/masto.js/) - Mastodon API client
- [Iconify](https://iconify.design/) - Icon library
- [MingCute icons](https://www.mingcute.com/)
- [Lingui](https://lingui.dev/) - Internationalization
- Vanilla CSS - _Yes, I'm old school._

Some of these may change in the future. The front-end world is ever-changing.

## Internationalization

All translations are available as [gettext](https://en.wikipedia.org/wiki/Gettext) `.po` files in the `src/locales` folder. The default language is English (`en`). [CLDR Plural Rules](https://cldr.unicode.org/index/cldr-spec/plural-rules) are used for pluralization. RTL (right-to-left) languages are also supported with proper text direction, icon rendering and layout.

On page load, default language is detected via these methods, in order (first match is used):

1. URL parameter `lang` e.g. `/?lang=zh-Hant`
2. `localStorage` key `lang`
3. Browser's `navigator.language`

Users can change the language in the settings, which sets the `localStorage` key `lang`.

### Guide for translators

*Inspired by [Translate WordPress Handbook](https://make.wordpress.org/polyglots/handbook/):

- [Don’t translate literally, translate organically](https://make.wordpress.org/polyglots/handbook/translating/expectations/#dont-translate-literally-translate-organically).
- [Try to keep the same level of formality (or informality)](https://make.wordpress.org/polyglots/handbook/translating/expectations/#try-to-keep-the-same-level-of-formality-or-informality)
- [Don’t use slang or audience-specific terms](https://make.wordpress.org/polyglots/handbook/translating/expectations/#try-to-keep-the-same-level-of-formality-or-informality)
- Be attentive to placeholders for variables. Many strings have placesholders e.g. `{account}` (variable), `<0>{name}</0>` (tag with variable) and `#` (number placeholder).
- [Ellipsis](https://en.wikipedia.org/wiki/Ellipsis) (…) is intentional. Don't remove it.
- Nielsen Norman Group: ["Include Ellipses in Command Text to Indicate When More Information Is Required"](https://www.nngroup.com/articles/ui-copy/)
- Apple Human Interface Guidelines: ["Append an ellipsis to a menu item’s label when the action requires more information before it can complete. The ellipsis character (…) signals that people need to input information or make additional choices, typically within another view."](https://developer.apple.com/design/human-interface-guidelines/menus)
- Windows App Development: ["Ellipses mean incompleteness."](https://learn.microsoft.com/en-us/windows/win32/uxguide/text-ui)
- Date timestamps, date ranges, numbers, language names and text segmentation are handled by the [ECMAScript Internationalization API](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl).
- [`Intl.DateTimeFormat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat) - e.g. "8 Aug", "08/08/2024"
- [`Intl.RelativeTimeFormat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat) - e.g. "2 days ago", "in 2 days"
- [`Intl.NumberFormat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat) - e.g. "1,000", "10K"
- [`Intl.DisplayNames`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames) - e.g. "English" (`en`) in Traditional Chinese (`zh-Hant`) is "英文"
- [`Intl.Locale`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale) (with polyfill for older browsers)
- [`Intl.Segmenter`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter) (with polyfill for older browsers)

### Technical notes

- IDs for strings are auto-generated instead of explicitly defined. Some of the [benefits](https://lingui.dev/tutorials/explicit-vs-generated-ids#benefits-of-generated-ids) are avoiding the "naming things" problem and avoiding duplicates.
- Explicit IDs might be introduced in the future when requirements and priorities change. The library (Lingui) allows both.
- Please report issues if certain strings are translated differently based on context, culture or region.
- There are no strings for push notifications. The language is set on the instance server.
- Native HTML date pickers, e.g. `<input type="month">` will always follow the system's locale and not the user's set locale.
- "ALT" in ALT badge is not translated. It serves as a a recognizable standard across languages.
- Custom emoji names are not localized, therefore searches don't work for non-English languages.
- GIPHY API supports [a list of languages for searches](https://developers.giphy.com/docs/optional-settings/#language-support).
- Unicode Right-to-left mark (RLM) (`U+200F`, `&rlm;`) may need to be used for mixed RTL/LTR text, especially for [`<title>` element](https://www.w3.org/International/questions/qa-html-dir.en.html#title_element) (`document.title`).
- On development, there's an additional `pseudo-LOCALE` locale, used for [pseudolocalization](https://en.wikipedia.org/wiki/Pseudolocalization). It's for testing and won't show up on production.
- When building for production, English (`en`) catalog messages are not bundled separatedly. Other locales are bundled as separate files and loaded on demand. This ensures that `en` is always available as fallback.

### Volunteer translations

[![Crowdin](https://badges.crowdin.net/phanpy/localized.svg)](https://crowdin.com/project/phanpy)

Translations are managed on [Crowdin](https://crowdin.com/project/phanpy). You can help by volunteering translations.

Read the [intro documentation](https://support.crowdin.com/for-volunteer-translators/) to get started.

## Self-hosting

This is a **pure static web app**. You can host it anywhere you want.
Expand Down Expand Up @@ -174,6 +230,9 @@ Available variables:
- `PHANPY_PRIVACY_POLICY_URL` (optional, default to official instance's privacy policy):
- URL of the privacy policy page
- May specify the instance's own privacy policy
- `PHANPY_DEFAULT_LANG` (optional):
- Default language is English (`en`) if not specified.
- Fallback language after multiple detection methods (`lang` query parameter, `lang` key in `localStorage` and `navigator.language`)
- `PHANPY_LINGVA_INSTANCES` (optional, space-separated list, default: `lingva.phanpy.social [...hard-coded list of fallback instances]`):
- Specify a space-separated list of instances. First will be used as default before falling back to the subsequent instances. If there's only 1 instance, means no fallback.
- May specify a self-hosted Lingva instance, powered by either [lingva-translate](https://github.com/thedaviddelta/lingva-translate) or [lingva-api](https://github.com/cheeaun/lingva-api)
Expand Down
7 changes: 7 additions & 0 deletions crowdin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
pull_request_labels:
- i18n
commit_message: New translations (%language%)
append_commit_message: false
files:
- source: /src/locales/en.po
translation: /src/locales/%locale%.po
20 changes: 20 additions & 0 deletions lingui.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { ALL_LOCALES } from './src/locales';

const config = {
locales: ALL_LOCALES,
sourceLocale: 'en',
pseudoLocale: 'pseudo-LOCALE',
fallbackLocales: {
default: 'en',
},
catalogs: [
{
path: '<rootDir>/src/locales/{locale}',
include: ['src'],
},
],
// compileNamespace: 'es',
orderBy: 'origin',
};

export default config;
Loading