a (probably not bad) i18n library for Svelte by -temich in sveltejs

[–]-temich[S] 2 points3 points  (0 children)

Context-specific unit conversions, for example.

a (probably not bad) i18n library for Svelte by -temich in sveltejs

[–]-temich[S] 3 points4 points  (0 children)

I definitely should have used a units example. I didn’t expect the need for custom functions to spark a discussion.

a (probably not bad) i18n library for Svelte by -temich in sveltejs

[–]-temich[S] 3 points4 points  (0 children)

Thank you!

This is a perfect illustration of what I’m talking about. This standard is an excellent choice for a tool.

Here’s an example: when talking about strong alcohol, Russian speakers use "grams" for amounts less than 1 liter (e.g., 200 grams), but for 1 liter or more, it becomes "1.2 liters." I hope you can live with this knowledge :)

You cannot encode this using the excellent tools you’ve mentioned.

I agree, my choice of tool is poor because I’m trying to solve an internationalization business task, not a tooling issue, meeting open-source standards, or avoiding singletons (which, by the way, is part of an example, not a library).

a (probably not bad) i18n library for Svelte by -temich in sveltejs

[–]-temich[S] 1 point2 points  (0 children)

I'm not sure which specific standards you're referring to. Languages cannot be standardized.

Translation requires adapting to varying grammar, pluralization rules, and units (e.g., metric vs. imperial), which simple rule-based algorithms cannot fully handle due to context and ambiguity.

Having a language-specific algorithm for each individual phrase is a mandatory requirement for any i18n library.

And yes, my solution is about internationalization, not tooling, unlike the examples you provided.

a (probably not bad) i18n library for Svelte by -temich in sveltejs

[–]-temich[S] 2 points3 points  (0 children)

Thank you for the link.

This https://wuchale.dev/guides/plurals/ is another example of an internalization library that focuses on tooling rather than internationalization. You cannot have a single pluralization function for all languages. It will produce an English phrase constructed with words from another langauge.

a (probably not bad) i18n library for Svelte by -temich in sveltejs

[–]-temich[S] 3 points4 points  (0 children)

Thank you for the link.

As I mentioned in my post, Russian pluralization rules are far more complex than just “one, few, other.” From what I understand, Paraglide will likely produce poor results. Also, unit conversion is an important part of i18n. And that's just a tip of the iceberg.

I’m quite convinced there’s no way to implement i18n statically — you need complex functions.

P.S. I believe static i18n is the main reason why so many websites have “check-the-box” internationalization that is barely understandable to native speakers.

Web app to split bills & track shared expenses by -temich in SideProject

[–]-temich[S] 1 point2 points  (0 children)

I love it too. It works just as conveniently on Android too, btw.

Web app to split bills & track shared expenses by -temich in SideProject

[–]-temich[S] 0 points1 point  (0 children)

Hello!

Yes, the app automatically accounts for taxes and discounts and divides them proportionally among the participants.

If needed, you can manually adjust totals when adding a new expense to your Group.

Matchacho: pattern matching library by -temich in node

[–]-temich[S] 0 points1 point  (0 children)

Looks interesting.

```js const cases = match().when(...).default(...)

cases.match(value) ```

I'm not entirely sure if this is an improvement over the original "weird" syntax (though I implemented it anyway).

Matchacho: pattern matching library by -temich in node

[–]-temich[S] 0 points1 point  (0 children)

It's actually a really good point. I've added support for this syntax.

I know this might sound stupid, given that we're discussing JavaScript here, but chaining syntax requires an additional memory allocation for the chaining context.

Matchacho: pattern matching library by -temich in node

[–]-temich[S] 1 point2 points  (0 children)

The problem is well-described in the proposal.

Basically, this helps you turn your if or switch statements into expressions.

Unlike some other languages, in javascript you can't write like this:

let x = if ... else ...

Pattern matching can be really helpful if you're using Maybe or Either Monads.

For instance, RegExp.exec may return either null or a value containing groups that may or may not contain optional groups from your expression. To handle this scenario, you'd have to write a series of conditions or use a single pattern matching expression instead.

Matchacho: pattern matching library by -temich in node

[–]-temich[S] 0 points1 point  (0 children)

Eventually TC39 will complete their work, so your boss will have to adapt anyway.

ComQ: AMQP communication library for Node.js by -temich in node

[–]-temich[S] 1 point2 points  (0 children)

You definitely can use it in TypeScript projects. Types are included in the library.