
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
@awes-io/nuxt-i18n
Advanced tools
Based on nuxt-i18n
This modules fetches translations into your Nuxj.js project from the given endpoint, and provides automatic nuxt-i18n
configuration.
yarn add @awes-io/nuxt-i18n
// nuxt.config.js
export default {
modules: ['@awes-io/nuxt-i18n'],
awesIo: {
nuxtI18n: {
locales: [
{ code: 'de-DE', domain: 'site.de' },
{ code: 'en-GB', domain: 'site.uk' }
]
// for same domain it could be even shorter: ['de-DE', 'en-GB']
}
}
}
That's it!
nuxt-i18n
// nuxt.config.js
export default {
i18n: {
defaultLocale: 'de', // first in array
locales: [
{
code: 'de',
iso: 'de-DE',
domain: 'site.de',
file: '/translations-de.js' // auto-generated file
},
{
code: 'en',
iso: 'en-GB',
domain: 'site.uk',
file: '/translations-en.js' // auto-generated file
}
],
differentDomains: true,
langDir: '.nuxt/awes-io/lang'
}
}
import axios from 'axios'
export default function() {
return new Promise((resolve) => {
axios
.get('/api/translations?locale={locale}')
.then(({ data }) => resolve(data.data))
.catch((e) => {
console.log(e)
resolve({})
})
})
}
By default, your server response should look like this:
// GET /api/translations?locale=de
{
"data": {
"hello": "Hallo",
"goodbye": "Auf Wiedersehen"
}
}
// GET /api/translations?locale=en
{
"data": {
"hello": "Hallo", // no translation - fallback to default language
"goodbye": "Goodbye"
}
}
And you can use it in templates:
<template>
<div>{{ $t('hello') }}</div>
</template>
Extend your basic config like this
// nuxt.config.js
export default {
i18n: {
vueI18n: {
fallbackLocale: 'de' // this will force to make additional request for default locale
}
},
awesIo: {
nuxtI18n: {
url: '/api/langs/{locale}', // insert {locale} for locale code interpolation
dataPath: 'my.lang' // set to 'false' for data without "wrapper", 'data' by default
// ... some other config
}
}
}
The response should look like this:
// GET /api/langs/de
{
"my": {
"lang": {
"hello": "Hallo",
"goodbye": "Auf Wiedersehen"
}
}
}
// GET /api/langs/en
{
"my": {
"lang": {
// no translation - no key in response
"goodbye": "Goodbye"
}
}
}
Note!
If you provide
url
with different domain, like this'https://another-site.io/api/langs/{locale}'
, be shure, to sendAccess-Control-Allow-Origin
header and supportHEAD
request method
Ensure to write proper commit message according to Git Commit convention
FAQs
Nuxt i18n module for loading translations from API endpoint
We found that @awes-io/nuxt-i18n demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers 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.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.