GitXplorerGitXplorer
P

ya-i18next-webpack-plugin

public
7 stars
1 forks
2 issues

Commits

List of commits on branch master.
Verified
4cc387f53a9753372e24248927df147b6463e5c6

Bump typescript from 3.5.2 to 3.6.3

ddependabot-preview[bot] committed 5 years ago
Verified
758d3b98ef790ea73017a2cbcb2685690d7ccc98

[Security] Bump mixin-deep from 1.3.1 to 1.3.2

ddependabot-preview[bot] committed 5 years ago
Verified
6f05a9152058393281f17dd04fe3a736cc9aaa75

Merge pull request #34 from Perlmint/dependabot/npm_and_yarn/types/node-12.6.2

PPerlmint committed 6 years ago
Verified
b3f71f478da388e8540f50da5588edd49ae22478

Merge pull request #33 from Perlmint/dependabot/npm_and_yarn/lodash-4.17.13

PPerlmint committed 6 years ago
Verified
b97d7c7945d5d2e0bcdb5431d04c9fec0a103297

Bump @types/node from 8.10.49 to 12.6.2

ddependabot-preview[bot] committed 6 years ago
Verified
29aff5eea58bf3c091c9232649ba9a0bf3e7fb6d

[Security] Bump lodash from 4.17.11 to 4.17.13

ddependabot-preview[bot] committed 6 years ago

README

The README file for this repository.

npm version Build Status Coverage Status dependencies Status devDependencies Status

ya-i18next-webpack-plugin

Yet another i18next webpack plugin

This plugin collects keys from webpack parsing phase, saves missing translations into specified path, copies translation files.

usage

webpack.config.js

const i18nextPlugin = require("ya-i18next-webpack-plugin").default;

module.exports = {
    plugins: [
        new i18nextPlugin({
            defaultLanguage: "en",
            languages: ["en", "ko"],
            functionName: "_t",
            resourcePath: "./locales/{{lng}}/{{ns}}.json",
            pathToSaveMissing: "./locales/{{lng}}/{{ns}}-missing.json"
        })
    ]
};

index.js

import * as i18next from 'i18next';
import * as Backend from 'i18next-xhr-backend';
import * as i18nConf from "ya-i18next-webpack-plugin/config";

if (window._t === undefined) {
	i18next
		.use(Backend)
		.init({
			fallbackLng: i18nConf.DEFAULT_NAMESPACE,
			whitelist: i18nConf.LANGUAGES,
			backend: {
				loadPath: `${__webpack_public_path__}${i18nConf.RESOURCE_PATH}`
			}
		});
	window._t = i18next.t;
}

console.log(_t("hello_world"));

example missing keys

{
	"hello_world": [
		"index.js(18,16)"
	],
}