Repository navigation
feat: multi-language support - #357
eramitgupta wants to merge 8 commits into
Conversation
…nguage Co-Authored-By: Claude Opus 5.5 <[email protected]>
The page now ships its UI translations, which include the generic "replying to" copy, so assert on the parent's handle instead. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nguage Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Hey @eramitgupta! Awesome work on bringing multi-language support to Just wanted to share two quick things that might help get this merged smoothly:
|
…nguage Translates the new upstream copy too: the image drop overlay, the quote reply labels, the GIF-free image error and the singular pastel count. Co-Authored-By: Claude Opus 5.5 <[email protected]>
feat: add Nepali language support and fix link preview test
…nguage Translates upstream's custom lane color option, and completes the Nepali files with the keys added since that PR branched (quoting labels, image drop overlay, GIF-free image error, singular pastel count). Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@nunomaduro This PR touches new third-party dependencies and configuration. Could you take a look? |
|
Note This message is generated by gpt-6.1-sol on behalf of xHeaven. It may contain errors—verify important details. The secret scanner and its warnings have been removed in #999. The scanner warning and confirmation strings no longer need translation. |
|
This out, hey, dude, I really appreciate all of your work on this. However, it does look too much in terms of files change, in terms of code, to actually just add multi-language support to the social media. We actually don't want that right now. It's a good idea in the future, but we want to table it for now because we really feel that it's just too soon to think about this. Thanks |
Multi-language support
devnull can now be used in 10 languages. English stays the default; anyone can switch under Settings → Appearance → Language, and the page re-renders in the new language without a full reload. Commits, names and bios stay in the language they were written in.
enhiesfrdept_BRzh_CNjarukoAll are left-to-right, so the layout doesn't change. Right-to-left languages (Arabic, Urdu) are not included.
The package
Translations use
erag/laravel-lang-sync-inertia(Laravel) and@erag/lang-sync-inertia(frontend), set up the way the package's own skill describes:lang/{locale}/{group}.php.php artisan erag:generate-langwrites them toresources/js/lang/{locale}/{group}.json.app()->getLocale()and shares it on every Inertia response as thelangprop. No middleware orsyncLangFiles()call is needed for these groups.Config is published at
config/inertia-lang.php(erag:install-lang) and keeps the defaults:lang_path=lang/,output_lang=resources/js/lang.Groups
navsettingssearchcomposercommitslogusersnotificationsHow the language is chosen
App\Enums\Locale: the supported languages.label()gives each one's name in its own language.localecookie: stores the choice, likeappearance. Added toencryptCookies(except: ...)because the browser writes it.App\Http\Middleware\HandleLocale: reads the cookie and callsApp::setLocale()when it's a supported language; anything else falls back to English. It only sets the locale and shares nothing.HandleInertiaRequests: shareslocale(current) andlocales({ value, label }[]) for the switcher.LanguageSelect: the dropdown on the Appearance page. It writes the cookie, updates<html lang>, and callsrouter.reload()so the server returns the page andlangprop in the new language.Guide: using translations in a component
@erag/lang-sync-inertia/react, not the package root. The root entry also loads the Vue and Svelte builds; the skill recommends the framework entry.useLang(), notreactLang()/lang(). They are the same hook, but the React Compiler only treatsuse*names as hooks. WithreactLang()it cached the result, so after switching languages part of the page kept the old one.usePage()). Helpers outside components take__/transChoiceas a parameter from the caller.group.section.key. A missing key renders the key itself, so every key you use must exist inlang/en.Placeholders and plurals
:name.transChoicepicks the first form for 1 and the last otherwise, and supports Laravel intervals ({0},[2,4],[5,*]). Russian uses intervals for its three forms; Chinese, Japanese and Korean repeat one form on both sides of|.Sentences around links or elements
__()returns a string, so a sentence containing a link is split into fragments (*_before,*_link,*_after) that each language fills in so it reads naturally.Guide: adding or changing text
lang/en/{group}.php.lang/{locale}/{group}.php.tests/Feature/TranslationsTest.phpfails if a language is missing a key, has an extra or empty one, changes the:placeholdersof a line, or if the JSON is out of date with the PHP files.Guide: adding a language
App\Enums\Localewith its native-namelabel()(and updateLocaleTest).lang/{locale}/with all 8 groups, translated, with the same keys aslang/en.php artisan erag:generate-langand commitresources/js/lang/{locale}/.The language then appears in the switcher automatically, and
TranslationsTestcovers it through the enum.Other changes
resources/js/lang/**is excluded fromvp fmt, like the generated Wayfinder folders, becauseerag:generate-langwrites 4-space JSON.tests/draft-images.config.tsinlines@erag/lang-sync-inertiafor vitest sousePagemocks reach the hook. Frontend tests that assert English text now pass alangprop.AppLayouthands it translated labels viauseUndoToastLabels().SegmentedControl: keys and view-transition names now come fromoption.valueinstead of the translated label.PageTabs: new optionalnameprop, a stable English name for the indicator's view-transition, so translated labels don't change it.formatDayLabel(): takes optional translated "Today" / "Yesterday" labels.min-w-*so translations don't shift the layout.Not translated yet
__()in PHP).3m,2h,5d); full dates use the browser's locale.devnull,/dev/null,stash@{0},HEAD,fatal:),@handles, hashes, keyboard keys and code samples.Testing
tsc, JS unit tests, PHPStan, Rector, Pint, 100% type coverage andbun run buildpass.LocaleTest: languages and native names.HandleLocaleTest: cookie, unsupported value, non-string value.HandleInertiaRequestsTest:localeandlocalesprops.TranslationsTest: key and placeholder parity, JSON up to date, and a page rendered in Hindi from the cookie.