Skip to content
JavaabuPublic

About

Laravel's __(), trans() and trans_choice() for JavaScript, with React, Vue, jQuery and vanilla JS support

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

@javaabu/i18n

Tests codecov npm License: MIT

Laravel's __(), trans() and trans_choice() for JavaScript, with the same arguments and the same output. It works with React, Vue, jQuery and vanilla JS, finds the locale from the page, knows RTL, and loads Laravel JS Localization, JSON, gettext, XLIFF, properties and ARB translations.

<Forms.Text name="message" :label="__('Message')" />

Documentation

You'll find the documentation on https://docs.javaabu.com/i18n, and in the docs folder.

AI coding assistants can start from llms.txt. The package ships a Laravel Boost skill and guideline, which Boost finds by itself. See AI assistants.

Quick start

pnpm add @javaabu/i18n
import { __, trans_choice, configure } from "@javaabu/i18n"

configure({ loader: (locale) => import(`../../lang/${locale}.json`) })

__("Welcome, :name!", { name: "Ali" })
trans_choice("messages.apples", 3)

Without a bundler:

<script src="https://unpkg.com/@javaabu/i18n/dist/i18n.iife.js"></script>
Using Read Example
React React examples/react.tsx
Vue Vue examples/App.vue
jQuery jQuery examples/jquery.ts
Vanilla JS Vanilla JS examples/vanilla.ts
Script tag Installation examples/script-tag.html

Run the examples with pnpm install && pnpm examples. Each one switches between Dhivehi and English.

Testing

pnpm test             # includes the comparison against test/parity/golden.json
pnpm test:coverage
pnpm build && pnpm test:browser
pnpm parity:generate  # refreshes that file from the real Laravel translator (needs PHP and Composer)

Changelog

Please see CHANGELOG for what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email info@javaabu.com instead of using the issue tracker.

License

MIT. See LICENSE.md.

About

Laravel's __(), trans() and trans_choice() for JavaScript, with React, Vue, jQuery and vanilla JS support

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages