metaframework agnostic i18n library #395
-
ProblemBuilding (sophisticated) i18n for metaframeworks is a month/year-long effort. For example, SvelteKit's most upvoted issues are about i18n and have been open for years sveltejs/kit#553, sveltejs/kit#1274. I18n in the context of metaframeworks is especially problematic because routing, SSR, SEO, "code splitting", and more needs to be considered.
ProposalProvide a framework-agnostic i18n library for metaframeworks with the possibility for deep integration via adapters. We have multiple components in
|
Beta Was this translation helpful? Give feedback.
Replies: 10 comments 31 replies
-
Features that immediately come to mind in the context of metaframeworks:
|
Beta Was this translation helpful? Give feedback.
-
That's great. As the author of vite-plugin-ssr, I'm very much interesed in this. Looking forward to playing around with a first draft of the library. |
Beta Was this translation helpful? Give feedback.
-
Really like the idea of it being compiler based. Would this mean it will scan the codebase, extract strings and autogenerate ids? Something along the lines of what formatjs is doing? Also, please keep edge in mind. Most i18n libraries I know use fs module from Node to fetch locales. fs isn't available in edge runtimes. Also, I am not a fan of "fetching" locale files after browser loads (which some libraries implement). Not good for SEO. I guess bundling locales is one option (but can easily shoot up in size and cross the worker size limitations imposed by edge runtimes - like Cloudflare Workers has a soft 1MB limit and hard 5MB limit AFAIK). Maybe provide adaptors to deploy to R2/S3 buckets? Just thinking out loud. |
Beta Was this translation helpful? Give feedback.
-
@samuelstroschein Sounds promising! The Sveltekit team seems to perpetually remain in analysis/paralysis with this, and with good reason. It's just way, way more complex than anyone would first suspect. Especially so if you want to support use cases of larger apps involving many languages, professional translation workflows etc. I think it actually makes a lot of sense for a dedicated team to work on this in a framework-agnostic, mostly reusable way because i18n is such a deep rabbit hole. Most i18n frameworks I've seen are just the same mistakes being made again and again due to the author's lack of experience with how translation actually works professionally. I do think however it would be problematic if this adapter and framework is tightly coupled in a not-so agnostic way with how the translation content is stored and translated. Let's say sveltekit is integrated with inlang. Could we then extract and import again all translations to other translation management systems, export into industry standard formats like XLIFF etc.? Meaning do we have to buy in to the "built on git" idea? I personally like it but for this to become truly universally useful and accepted it would need to work with everyone's own choice of translation workflow. |
Beta Was this translation helpful? Give feedback.
-
Your rationale and proposal in on point. i18n has been an issue for too long, proven to be a complex issue bigger than any framework; so having a dedicated team / effort makes a lot of sense to me. Thank you for taking the initiative. I believe there is already a lot of effort going on for this, maybe not necessarily with the same philosophy as yours but certainly with the same intention of unifying the toolsets for i18n. Reminds me of @ivanhofer with his pipeli18ne project (sorry for tagging, thought you might have some thoughts here). |
Beta Was this translation helpful? Give feedback.
-
Love this idea to try and solve i18n via adapters, kind of like how meta frameworks are solving deployment target via adapters; Regarding i18n@samuelstroschein, have you seen the message format Github Repo which implements the ICU Message format which is a standard used in other programming languages for i18n & is a project of the Open JS Foundation. We should see if it makes sense to build on standards so we can increase compatibility of tooling across the ecosystem, if possible. Shoutout to @ivanhofer who's exploring i18n as well with his pipeli18ne which is in RFC/exploratory phases Random asideThis metaframework agnostic effort reminds me of recent initiative(s) which are also trying to solve problems in framework agnostic ways & helping metaframeworks & authors consolidate on solution(s) together. Plugging these projects, below in case people want to reach out to other framework creators |
Beta Was this translation helpful? Give feedback.
-
For metaframeworks that use a file-based router, how would routes be localised? Having to keep translations spread across multiple files (say that each route gets its own file) is tedious, also having to manually register a route in a single file is tedious. |
Beta Was this translation helpful? Give feedback.
-
Hey folks, we have some great news to share! I have written a few lines on how we could implement it. See here. |
Beta Was this translation helpful? Give feedback.
-
Hey @ivanhofer, is there a good guide to use typesafe-i18n with inlang? I know the plugin exists, but can't seem to get it working. |
Beta Was this translation helpful? Give feedback.
-
@samuelstroschein I think we now have the solution with Paraglide JS :) |
Beta Was this translation helpful? Give feedback.
@samuelstroschein I think we now have the solution with Paraglide JS :)