GitXplorerGitXplorer
P

ya-i18next-webpack-plugin

public
7 stars
1 forks
2 issues

Commits

List of commits on branch master.
Unverified
87216a57c2411111d7f39b16ba569ef11139c6d4

0.5.0

PPerlmint committed 4 years ago
Unverified
e1e0e3ec372eb07f8e8a65fcda61546a2b24fe66

Migrate to webpack5

PPerlmint committed 4 years ago
Verified
410daa4aa2d69140a9950c1cad8d86f800326cf1

Merge pull request #75 from Perlmint/dependabot/npm_and_yarn/handlebars-4.6.0

PPerlmint committed 5 years ago
Verified
806e4691af84e0ab52c7569ee6fe714a6090e793

[Security] Bump handlebars from 4.1.2 to 4.6.0

ddependabot-preview[bot] committed 5 years ago
Verified
abcf6fdb46a43f171c370ba625a82835200460d4

Merge pull request #60 from Perlmint/dependabot/npm_and_yarn/mixin-deep-1.3.2

PPerlmint committed 5 years ago
Verified
516e288beb1aa295679e34c97a9f858773e84739

Merge pull request #71 from Perlmint/dependabot/npm_and_yarn/typescript-3.6.3

PPerlmint committed 5 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)"
	],
}