@wuchale/svelte
0.20.5
Section titled “0.20.5”Patch Changes
Section titled “Patch Changes”- b9cd9b4: Fix error on
on:directives without expressions likeon:submit|preventDefault(#415) - b7826cf: Fix
{const x = $derived(...)}being wrapped in another$derived#416
0.20.4
Section titled “0.20.4”Patch Changes
Section titled “Patch Changes”- c46696a: Fix new mixed visitor visiting ignored elements when nested #408
- Updated dependencies [c46696a, 40b5c42]:
- wuchale@0.25.6
0.20.3
Section titled “0.20.3”Patch Changes
Section titled “Patch Changes”- d4ef202: Fix inconsistent handling of nested messages with non-nestable block types #402
- Updated dependencies [d4ef202]:
- wuchale@0.25.4
0.20.2
Section titled “0.20.2”Patch Changes
Section titled “Patch Changes”- fa12c12: Limit nesting to only element-like nodes to fix unexpected errors (e.g. around
{#if}) - Updated dependencies [fa12c12]:
- wuchale@0.25.3
0.20.1
Section titled “0.20.1”Patch Changes
Section titled “Patch Changes”-
Redo nested message visit algorithm (#393)
This release is all about the core of wuchale, i.e. the nested message visitor. It has now been vastly improved with a more solid approach.
-
Updated dependencies [
3c88ee9]:- wuchale@0.25.0
0.20.0
Section titled “0.20.0”Minor Changes
Section titled “Minor Changes”-
Add support for the new
{let/const ...}syntax (f502d12) -
⚠️ BREAKING: reorganize loading config, use glob patterns and number load IDs (#355)
granularLoadis nowloading.granularbundleLoadis nowloading.directgenerateLoadIDis replaced by a glob config atloading.group
Therefore if you use any of these, update your config like this:
import { defineConfig, defaultGenerateLoadID, pofile } from "wuchale"import { defineConfig, pofile } from "wuchale"import { adapter as svelte } from '@wuchale/svelte'export default defineConfig({// ...adapters: {main: svelte({// ...bundleLoad: true,granularLoad: true,generateLoadID: filename => {if (filename.includes('grouped')) {return 'grouped'}return defaultGenerateLoadID(filename)},loading: {granular: true,direct: true,group: ['**/*grouped*',]}}),}})
Patch Changes
Section titled “Patch Changes”-
Visit
svelte:elements as any other element (#379) -
⚠️ BREAKING: proxies now export
loadCountinstead ofloadIDsafter #355 (f903655)The default loaders have been updated to match but if you use
loadLocalesin SvelteKit hooks or Astro middlewares, you should update them like:await loadLocales(main.key, main.loadIDs, main.loadCatalog, locales)await loadLocales(main.key, main.loadCount, main.loadCatalog, locales) -
⚠️ BREAKING: Rename config
hmrtodevwith the following options to control behavior during dev: (#377)false: Same behavior as the previoushmr: false'read': Only uses existing translations and doesn’t add newly detected messages during dev'add': Adds newly detected messages and updates their refs as they get referenced, but doesn’t touch existing messages'refs': Same behavior as the previoushmr: true, adds new messages, updates refs and marks obsoletes'clean': Full behavior same asnpx wuchale --clean, deletes unused messages
-
Updated dependencies [
2005ea1,89b650b,94ce7fc,4899ae6,f903655,4bbbbae,589fbca,4922b03,3567c7f,2521033,5063533,6d5e244]:- wuchale@0.24.0
0.19.4
Section titled “0.19.4”Patch Changes
Section titled “Patch Changes”-
Include navigation and path functions as url calls in SvelteKit default heuristic (#327)
-
Use SvelteKit default heuristic only when loader is set to
sveltekit, otherwise plain Svelte heuristic (4b3cc91) -
Updated dependencies [
e5306c2,2d8462e,ba05cf2]:- wuchale@0.23.0
0.19.3
Section titled “0.19.3”Patch Changes
Section titled “Patch Changes”-
Fix on:… attributes and @html tags not visited (
a79e5df) -
Fix unrelated export statement affecting chosen runtime for non module
<script>(ce9ecfe) -
Fix $props with default value string being wrapped in $derived (
44ceec8) -
Updated dependencies [
ffc5d2a,f510e3a,5ad8f3a,9c7b6e9,43fabca,808edcf,8f2cfd6,f0feafb,92dbf5f,31ed422,62c3691,44ceec8]:- wuchale@0.22.1
0.19.2
Section titled “0.19.2”Patch Changes
Section titled “Patch Changes”- Updated dependencies [
89fec64,d53178a,2f195f3,346f49f,654b5e9,85c7473,eb49dc8,3371f37,8c9d854,b7f362c,8771568]:- wuchale@0.22.0
0.19.1
Section titled “0.19.1”Patch Changes
Section titled “Patch Changes”-
Fix
$state.*etc. being wrapped in$derivedcausing errors (e1ff6f6) -
Updated dependencies [
333c64a,d8a45ef]:- wuchale@0.21.2
0.19.0
Section titled “0.19.0”Minor Changes
Section titled “Minor Changes”-
Add support for importing a URL localize function from any module at runtime (
347ca5e)This adds support for cases where complete flexibility is needed for URLs, for example when the site targets different domain names for different locales, and when one locale can be used in different domains. Now a custom localize function that does the localization can be implemented, and wuchale only handles the translation. This can be used by providing the module path:
export default {// ...adapters: {svelte({url: {localize: 'src/lib/url-util.js',patterns: [// ...]}})}}The module has to export a
localizefunction that is of type:type URLLocalizer = (url: string, locale: string) => string;To just use the default of prefixing the locale to the path, set
localize: true.
Patch Changes
Section titled “Patch Changes”0.18.2
Section titled “0.18.2”Patch Changes
Section titled “Patch Changes”-
Store references for URL items just like any other message, and use it to avoid startup visit (#250)
-
Updated dependencies [
8ff01c4,843544b,69408f9]:- wuchale@0.20.0
0.18.1
Section titled “0.18.1”Patch Changes
Section titled “Patch Changes”-
Fix possible infinite retries on ai translate error/mistake (
2b9a61a) -
Updated dependencies [
2b9a61a]:- wuchale@0.19.1
0.18.0
Section titled “0.18.0”Minor Changes
Section titled “Minor Changes”-
9de6b79: Make it easier to choose non-reactive runtime function
by setting
runtime.useReactivein the adapter config. -
64f7485: BREAKING: Update locales config to support for 3rd party component libraries
The
sourceLocaleis now configured on a per-adapter basis, and on the top level, all desiredlocaleshave to be specified.You have to make some changes to your config:
{sourceLocale: 'en',otherLocales: ['es', 'fr'],locales: ['en', 'es', 'fr'],adapters: {main: svelte({sourceLocale: 'en',// ...})}}Additionally, the
sourceLocaleon the adapter defaults to the first locale in the mainlocalesarray.This allows the use of multiple languages in the source code, which may be necessary when you are trying to write the source in another language and you want to use a 3rd party lib written in English for example.
And now to use 3rd party component libraries, you can specify the file locations in the package dir under
node_modules:wuchale.config.js {//...adapters: {lib: svelte({files: "node_modules/foo-lib/dist/*.svelte",});}}And additionally, to make sure that Vite doesn’t interfere during dev, you can exclude the library from startup optimization:
vite.config.js export default defineConfig({optimizeDeps: {exclude: ["foo-lib"],},}); -
f92c641: Use
_w_runtime_(...)instead of_w_runtime_.t(...)to further reduce bundle size
Patch Changes
Section titled “Patch Changes”- Updated dependencies [3ca7aac]
- Updated dependencies [9de6b79]
- Updated dependencies [fad845d]
- Updated dependencies [197bb11]
- Updated dependencies [64f7485]
- Updated dependencies [63fb176]
- Updated dependencies [f92c641]
- wuchale@0.19.0
0.17.9
Section titled “0.17.9”Patch Changes
Section titled “Patch Changes”-
434169d: Fix problems when using snippets as optional props mixed with text
When using them as shown in here.
0.17.8
Section titled “0.17.8”Patch Changes
Section titled “Patch Changes”- 5f336b8: Fix undeclared deps causing ‘Config not found’ error #207
- Updated dependencies [926aa60]
- Updated dependencies [7471ce3]
- wuchale@0.18.8
0.17.7
Section titled “0.17.7”Patch Changes
Section titled “Patch Changes”- 82c4cf9: Fix
<style lang="scss">causing problems in Svelte - Updated dependencies [82c4cf9]
- wuchale@0.18.7
0.17.6
Section titled “0.17.6”Patch Changes
Section titled “Patch Changes”- 0a4e3df: Remove surrounding unnecessary quotes when transforming attributes #191
- 885c131: Fix type errors because of generated compiled catalogs not being typed
- Updated dependencies [6af0d52]
- Updated dependencies [0a4e3df]
- Updated dependencies [1b511c3]
- Updated dependencies [5ce8212]
- Updated dependencies [885c131]
- wuchale@0.18.6
0.17.5
Section titled “0.17.5”Patch Changes
Section titled “Patch Changes”- f861f78: Use proper hook name to get reactive runtime in React #181
- Updated dependencies [44a6d24]
- Updated dependencies [f861f78]
- wuchale@0.18.5
0.17.4
Section titled “0.17.4”Patch Changes
Section titled “Patch Changes”- a1a31f9: Fix errors during build due to granular load IDs and TS types
- Updated dependencies [a1a31f9]
- wuchale@0.18.3
0.17.3
Section titled “0.17.3”Patch Changes
Section titled “Patch Changes”- db45dff: Fix default loader templates, remove obsolete comments
- 5b0a570: Fix
customloader in config causing errors - Updated dependencies [4a8ba3d]
- Updated dependencies [db45dff]
- Updated dependencies [5b0a570]
- wuchale@0.18.2
0.17.2
Section titled “0.17.2”Patch Changes
Section titled “Patch Changes”- 12d17f7: Fix inconsistent wuchale versions
0.17.1
Section titled “0.17.1”Patch Changes
Section titled “Patch Changes”- 3d451d3: Update after fix compiled catalogs writing
0.17.0
Section titled “0.17.0”Minor Changes
Section titled “Minor Changes”-
37deb80: Always use physical files, change
catalogconfig tolocalesDirPreviusly virtual modules offered by Vite made it possible to keep the file system clean and a slight performance advantage when building, but they had disadvantages:
- Inspecting what Wuchale generates was not possible unless the
writeFilesconfig was enabled - They don’t work outside of Vite
- Supporting physical files was therefore unavoidable and that meant supporting two different systems to export the same things
Now everything is written to disk, including proxies, compiled catalogs, and locales data too. And
writeFileshas been removed. In cases where writing the transformed code is desired, the destination can be provided to theoutDiradapter config.The second thing is that the location of the catalog files was previusly specified using the
catalogadapter config, which accepted a substitution parameter,{locale}but it’s an unnecessary complexity that can lead to problems, and it’s not just catalogs that’s stored in that location. Therefore, it has been replaced by the self descriptive config,localesDir. - Inspecting what Wuchale generates was not possible unless the
-
37deb80: Removed the
initCLI command. Loaders are now specified in the config. And they have to exportgetRuntimeandgetRuntimeRx.The interactive
initcommand was mainly created to scaffold loaders. But since most devs don’t touch the loaders and since updates to what the loaders are expected to export and their locations is not that straightforward to keep up with the package updates, the command has been removed, and the loaders can be specified in the adapter configuration using the keyloader.The loader config can take some default included loaders and additionally
customas a value. For example, the Svelte adapter can accept the valuessvelte,sveltekitandcustom.Specifying the included loaders (
svelteorsveltekitin the example case) means you don’t want to control their content and want to use the default. And so the loader(s) contents are (over)written at dev server startup or theextractcommand. That way, they are automatically kept up to date with the package. But if you want to do custom stuff with the loaders, and don’t want them to be overwritten, you can specifycustom.The location of the loaders is next to the catalogs, and follows this naming convention:
{adapter key}.loader[.server].{loader extension}For example, for a SvelteKit project, it can be:
main.loader.svelte.js(client) andmain.loader.server.svelte.js(server). Therefore, if you take ownership of these files and do custom stuff, you can specifycustomin the adapter config.And next, the (custom) loaders have to export functions
getRuntimeandgetRuntimeRxafter wrapping the loaded catalogs withtoRuntimefromwuchale/runtime. -
9d1dff8: Add support for translating URL paths!
This is the biggest addition on this release. Internationalizing URL paths is now possible, with the same conveniences of no/minimal code changes, while respecting the fact that URLs are to be handled carefully.
There are two parts to this:
- Translation: e.g.
/aboutto/uber-uns - Localization: e.g.
/aboutto/en/about
Full guide coming soon in the docs!
- Translation: e.g.
Patch Changes
Section titled “Patch Changes”- Updated dependencies [37deb80]
- Updated dependencies [37deb80]
- Updated dependencies [37deb80]
- Updated dependencies [37deb80]
- Updated dependencies [37deb80]
- Updated dependencies [9d1dff8]
- wuchale@0.18.0
0.16.6
Section titled “0.16.6”Patch Changes
Section titled “Patch Changes”- 5c8cea6: Fix chain expressions (JS) and render tags (Svelte) not being visited
- Updated dependencies [5c8cea6]
- wuchale@0.17.5
0.16.5
Section titled “0.16.5”Patch Changes
Section titled “Patch Changes”- d790b4b: Fix auto wrapping exported variables with
$derivedcausing errors - a955579: Visit @const declarations in svelte, more compatibility
- Updated dependencies [a955579]
- wuchale@0.17.4
0.16.4
Section titled “0.16.4”Patch Changes
Section titled “Patch Changes”- f18aeda: Fix $state being wrapped in $derived when it has messages
0.16.3
Section titled “0.16.3”Patch Changes
Section titled “Patch Changes”- 77430e7: Fix error when exporting types from script modules
0.16.2
Section titled “0.16.2”Patch Changes
Section titled “Patch Changes”- b30885a: Fix
$propsbeing wrapped in$derivedwhen it shouldn’t
0.16.1
Section titled “0.16.1”Patch Changes
Section titled “Patch Changes”- 8e2611d: Export and document all default heuristic functions
- 088c748: Fix errors when exporting snippets with messages
- Updated dependencies [6a9b651]
- Updated dependencies [8e2611d]
- wuchale@0.17.1
0.16.0
Section titled “0.16.0”Minor Changes
Section titled “Minor Changes”-
0b5c207: Svelte: auto wrap variable declarations by
$derivedas needed instead of requiring it in the code -
d531bcc: Add support for multiple custom patterns to support full l10n
For example, if you want to use
Intl.MessageFormatfor everything it supports including plurals, you add a signature pattern for a utility function in the config:// ...adapters: js({patterns: [{name: "formatMsg",args: ["message", "other"],},],});//...Then you create your reusable utility function with that name:
// where you get the localelet locale = "en";export function formatMsg(msg, args) {return new IntlMessageFormat(msg, locale).format(args);}And use it anywhere:
const msg = formatMsg(`{numPhotos, plural,=0 {You have no photos.}=1 {You have one photo.}other {You have # photos.}}`,{ numPhotos: 1000 });Then wuchale will extract and transform it into:
const msg = formatMsg(_w_runtime_.t(0), { numPhotos: 1000 });
Patch Changes
Section titled “Patch Changes”- 15cf377: Pass whole message to heuristic function, with context
- 16b116c: Customizable log levels, add verbose level where all extracted messages are shown
- Updated dependencies [5a221a2]
- Updated dependencies [15cf377]
- Updated dependencies [0b5c207]
- Updated dependencies [16b116c]
- Updated dependencies [22198c1]
- Updated dependencies [6d0a4d3]
- Updated dependencies [d531bcc]
- Updated dependencies [9f997c2]
- wuchale@0.17.0
0.15.1
Section titled “0.15.1”Patch Changes
Section titled “Patch Changes”- 5aa768a: Ignore form method attribute and fetch calls
- 04e28a3: Fix initialization outside
<script>when the<script>is empty - Updated dependencies [5aa768a]
- Updated dependencies [0352c60]
- Updated dependencies [04e28a3]
- wuchale@0.16.4
0.15.0
Section titled “0.15.0”Minor Changes
Section titled “Minor Changes”-
fef0d11: Add the
@wc-ignore-filecomment directiveAs an alternative to ignoring a file in the
filesconfig value, you can now ignore a whole file by putting this directive at the beginning of the file, before any extractable messages. The advantage is that it doesn’t need a restart of the dev server and if you rename/move the file it will always be ignored.
Patch Changes
Section titled “Patch Changes”- b6eb03c: Fix error on interpolations inside
- Updated dependencies [fef0d11]
- Updated dependencies [4fcf264]
- Updated dependencies [46aa3f2]
- Updated dependencies [37367ca]
- Updated dependencies [f07d484]
- wuchale@0.16.0
0.14.3
Section titled “0.14.3”Patch Changes
Section titled “Patch Changes”- 3d5d73a: Solve issues with paths on windows
- Updated dependencies [3d5d73a]
- wuchale@0.15.8
0.14.2
Section titled “0.14.2”Patch Changes
Section titled “Patch Changes”- 485f5fe: Fix .svelte files with