Git Product home page Git Product logo

nubolab-ffwd / svelte-fluent Goto Github PK

View Code? Open in Web Editor NEW
81.0 3.0 1.0 31.67 MB

svelte-fluent is a powerful localization library for Svelte and SvelteKit that enables you to integrate translations using Mozilla's natural-sounding Fluent syntax easily.

Home Page: https://nubolab-ffwd.github.io/svelte-fluent/

License: MIT License

JavaScript 13.73% Svelte 59.48% HTML 0.43% CSS 9.35% TypeScript 15.16% Fluent 1.85%
fluent i18n javascript l10n rollup sapper svelte sveltejs sveltekit vite

svelte-fluent's People

Contributors

dependabot[bot] avatar github-actions[bot] avatar renovate-bot avatar renovate[bot] avatar sfriedel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

sagudev

svelte-fluent's Issues

Error when getting a message that has only attributes

We may need a message with only attributes, then our Svelte code will be something like:

<Localized id="foo" let:attrs>
 <p>{attrs.paragraph1}</p>
</Localized>

But it crashes when loading a message like this one:

foo =
  .bar = example

while it works in this case:

foo = fix
  .bar = example

Error log:

TypeError: Invalid value used in weak set
    at WeakSet.add (<anonymous>)
    at resolveComplexPattern (resolver.js:232:17)
    at FluentBundle.formatPattern (bundle.js:150:25)
    at FluentProvider.svelte:27:25
    at $$self.$$.update (Localized.svelte:7:19)
    at init (index.mjs:2027:8)
    at new Localized (Localized.svelte:7:43)
    at Array.create_default_slot (RowWhatIsGambiConf.svelte:37:28)
    at create_slot (index.mjs:71:28)
    at create_fragment (Window.svelte:46:23)

Breaks with Svelte Devtools

(Or at least, the stack trace blames this)

With the dev tools closed. everything seems fine. but after opening it and clicking to enable. this stack trace gets printed every reload. and overlays are broken (regular translations seem to work fine) until you close the tab and open another one.

console-export-2023-6-14_15-48-52.txt

Dependencies list pruned only to ones I believe are relevant:

	"devDependencies": {
		"@nubolab-ffwd/svelte-fluent": "^0.6.1",
		"@sveltejs/adapter-node": "^1.2.4",
		"@sveltejs/adapter-static": "^2.0.2",
		"@sveltejs/kit": "^1.5.0",
		"svelte": "^3.54.0",
		"svelte-check": "^3.0.1",
		"vite": "^4.3.0"
	},
	"dependencies": {
		"@fluent/bundle": "^0.18.0",
		"@fluent/langneg": "^0.7.0",
		"accept-language-parser": "^1.5.0",
		"jsdom": "^22.1.0",
	}

plus Svelte DevTools 1.3.0

Allow to change the `Localized`/`Overlay` element type

Currently, <Overlay> outputs a <span> wrapping the result:

<Overlay id="foo">

outputs something like:

<span>foo text</span>

But we may need to render a specific element, such as <p>.

Perhaps we can use <svelte:element> and let the user decides which element is better for the use case, defaulting to <p> if no one is defined.

The same can be useful for <Localized>.
Currently, it doesn't have a wrapper element. Then, if we need to wrap it, we need to write more:

<Localized id="foo" let:text>
  <p>{text}</p>
</Localized>

If would be good if we could have an API like this:

<Localized id="foo" element="p" />

Including non-printable UNICODE characters⁨⁩ `U+2068` and `U+2069` before/after a placement

I don't know if it's expected, but I noticed that when using a placement, this library includes the UNICODE characters U+2068 and U+2069.

You can reproduce it by doing the following:

message = -{ $foo }-
<script>
  import { Localized } from "@nubolab-ffwd/svelte-fluent"
</script>

<Localized id="message" args={{ foo: 'value' }} let:text>
  {console.log(text)}
</Localized>

Then, copy the console output on VS Code:

image

It usually isn't a big deal, but if you are using the output on the img src attribute or making a string comparison, it can be bad.

HMR error in development server with sveltekit >=1.8.0

Hello - thanks for this library!

I took version 0.4.3 (a year old) for a spin, but it doesn't work with the latest sveltekit.

Would you be able to publish a new release to npm? It looks like a lot of changes were made in the past year.

Many thanks,
Aslak Hellesøy

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/docs-site.yml
  • actions/checkout v4.1.1
  • pnpm/action-setup v3.0.0
  • actions/setup-node v4.0.2
  • peaceiris/actions-gh-pages v4.0.0
.github/workflows/release.yml
  • google-github-actions/release-please-action v4
  • actions/checkout v4.1.1
  • pnpm/action-setup v3.0.0
  • actions/setup-node v4.0.2
.github/workflows/test.yml
  • actions/checkout v4.1.1
  • pnpm/action-setup v3.0.0
  • actions/setup-node v4.0.2
  • actions/checkout v4.1.1
  • pnpm/action-setup v3.0.0
  • actions/setup-node v4.0.2
  • actions/checkout v4.1.1
  • pnpm/action-setup v3.0.0
  • actions/setup-node v4.0.2
npm
package.json
  • @fluent/dom ^0.9.0
  • @fluent/sequence ^0.8.0
  • cached-iterable ^0.3.0
  • @commitlint/cli 19.2.1
  • @commitlint/config-conventional 19.1.0
  • @fluent/bundle 0.18.0
  • @fluent/langneg 0.7.0
  • @fontsource-variable/manrope 5.0.19
  • @iconify-json/mdi 1.1.66
  • @sveltejs/adapter-static 3.0.1
  • @sveltejs/kit 2.5.5
  • @sveltejs/package 2.3.1
  • @sveltejs/vite-plugin-svelte 3.1.0
  • @testing-library/svelte 4.1.0
  • @types/hast 3.0.4
  • @types/jsdom 21.1.6
  • @types/semver 7.5.8
  • @typescript-eslint/eslint-plugin 7.6.0
  • @typescript-eslint/parser 7.6.0
  • @vitest/ui 1.5.0
  • autoprefixer 10.4.19
  • eslint 8.57.0
  • eslint-config-prettier 9.1.0
  • eslint-plugin-svelte 2.37.0
  • glob 10.3.12
  • hast-util-heading-rank 3.0.0
  • hast-util-to-string 3.0.0
  • husky 9.0.11
  • lint-staged 15.2.2
  • mdsvex 0.11.0
  • npm-run-all2 6.1.2
  • pathe 1.1.2
  • postcss 8.4.38
  • postcss-load-config 5.0.3
  • postcss-preset-env 9.5.5
  • prettier 3.2.5
  • prettier-plugin-svelte 3.2.3
  • publint 0.2.7
  • rehype-add-classes 1.0.0
  • rehype-autolink-headings 7.1.0
  • rehype-external-links 3.0.0
  • rehype-shift-heading 2.0.0
  • rehype-slug 6.0.0
  • rehype-wrap-all 1.1.0
  • semver 7.6.0
  • shiki 1.3.0
  • svelte 4.2.13
  • svelte-check 3.6.9
  • svelte2tsx 0.7.6
  • tslib 2.6.2
  • typescript 5.4.5
  • unist-util-visit 5.0.0
  • unplugin-icons 0.18.5
  • vitest 1.5.0
  • jsdom ^20.0.0 || ^21.0.0 || ^22.0.0 || ^23.0.0 || ^24.0.0
  • rollup ^4.0.0
  • svelte ^3.55.0 || ^4.0.0
  • vite ^5.0.12

  • Check this box to trigger a request for Renovate to run again on this repository

`TypeError: Cannot read properties of undefined (reading '$$')`

Hello, thanks for the package!
I'm trying to use this package on my personal project built with SvelteKit, but I have the following error:

index.mjs:307 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading '$$')
    at init (index.mjs:307:50)

It refers to the following line:
image

I tried to fix it by adding a parent to FluentProvider, but it didn't fix that.

Commit with the changes: gambiconf/gambiconf.github.io@a4f61cb
You can easily follow the project readme to reproduce it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.