Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
sveltekit-i18n
Advanced tools
sveltekit-i18n
is a tiny, dependency-less library built for Svelte and SvelteKit.
✅ SvelteKit ready
✅ SSR support
✅ Custom data sources – no matter if you are using local files or remote API to get your translations
✅ Module-based – your translations are loaded for visited pages only (and only once!)
✅ Component-scoped translations – you can create multiple instances with custom definitions
✅ Custom modifiers – you can modify the input data the way you really need
✅ TS support
✅ No dependencies
Setup translations.js
in your lib folder...
import i18n from 'sveltekit-i18n';
export const config = ({
loaders: [
{
locale: 'en',
key: 'common',
loader: async () => (
await import('./en/common.json')
).default,
},
{
locale: 'en',
key: 'home',
routes: ['/'],
loader: async () => (
await import('./en/home.json')
).default,
},
{
locale: 'en',
key: 'about',
routes: ['/about'],
loader: async () => (
await import('./en/about.json')
).default,
},
{
locale: 'cs',
key: 'common',
loader: async () => (
await import('./cs/common.json')
).default,
},
{
locale: 'cs',
key: 'home',
routes: ['/'],
loader: async () => (
await import('./cs/home.json')
).default,
},
{
locale: 'cs',
key: 'about',
routes: ['/about'],
loader: async () => (
await import('./cs/about.json')
).default,
},
],
});
export const { t, locale, locales, loading, loadTranslations } = new i18n(config);
...include your translations in __layout.svelte
...
<script context="module">
import { loadTranslations } from '$lib/translations';
export const load = async ({ page }) => {
const { path } = page;
const locale = 'en'; // get from cookie or user session...
await loadTranslations(locale, path);
return {};
}
</script>
...and use your placeholders within pages and components.
<script>
import { t } from '$lib/translations';
const pageName = 'This page is Home page!';
</script>
<div>
<!-- you can use `placeholders` and `modifiers` in your definitions (see docs) -->
<h2>{$t('common.page', { pageName })}</h2>
<p>{$t('home.content')}</p>
</div>
FAQs
Internationalization library for SvelteKit
The npm package sveltekit-i18n receives a total of 7,659 weekly downloads. As such, sveltekit-i18n popularity was classified as popular.
We found that sveltekit-i18n demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.