PHPackages                             tomk79/px2-i18n - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Localization &amp; i18n](/categories/localization)
4. /
5. tomk79/px2-i18n

ActiveLibrary[Localization &amp; i18n](/categories/localization)

tomk79/px2-i18n
===============

0.1.0(3y ago)019MITJavaScriptPHP &gt;=7.3.0

Since Jul 18Pushed 3y ago1 watchersCompare

[ Source](https://github.com/tomk79/px2-i18n)[ Packagist](https://packagist.org/packages/tomk79/px2-i18n)[ RSS](/packages/tomk79-px2-i18n/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (20)Versions (5)Used By (0)

tomk79/px2-i18n
===============

[](#tomk79px2-i18n)

[Pickles 2](https://pickles2.pxt.jp/) で制作するウェブサイトを、多言語に対応させるプラグインです。

導入手順 - Setup
------------

[](#導入手順---setup)

### 1. composer.json に tomk79/px2-i18n を追加

[](#1-composerjson-に-tomk79px2-i18n-を追加)

`require` の項目に、`tomk79/px2-i18n` を追加します。

```
$ composer require tomk79/px2-i18n;

```

### 2. config.php に、設定を追加

[](#2-configphp-に設定を追加)

設定ファイル `config.php` (通常は `./px-files/config.php`) を編集します。

#### 対応する言語の設定

[](#対応する言語の設定)

```
/** デフォルトの言語 */
$conf->default_lang = 'ja';

/** 対応する言語 */
$conf->accept_langs = array('en', 'zh-CN', 'zh-TW', 'ko');
```

#### サイトマップの多言語化

[](#サイトマップの多言語化)

`$conf->funcs->before_sitemap` の最後に `tomk79\pickles2\px2I18n\loader::site()` を追加します。

```
/**
 * funcs: Before sitemap
 *
 * サイトマップ読み込みの前に実行するプラグインを設定します。
 */
$conf->funcs->before_sitemap = array(

    /* 中略 */

    // カスタムサイトマップオブジェクトを生成して登録する
    tomk79\pickles2\px2I18n\loader::site(),

    // LangBank を `$px->lb` に登録する
    tomk79\pickles2\px2I18n\loader::langbank( [
		"path_csv" => "/realpath/to/language.csv",
	] ),
);
```

#### Broccoliテキスト入力フィールドの多言語化

[](#broccoliテキスト入力フィールドの多言語化)

```
/** カスタムフィールドを登録 */
$conf->plugins->px2dt->guieditor->custom_fields = array(
	'text'=>array(
		'backend'=>array(
			'class' => 'tomk79\\pickles2\\px2I18n\\fields\\text',
			'require' => 'path/to/vendor/tomk79/px2-i18n/fields/i18n_text/backend/text.js',
		),
		'frontend'=>array(
			'dir' => 'path/to/vendor/tomk79/px2-i18n/fields/i18n_text/frontend/',
			'file' => array(
				'text.css',
				'text.js'
			),
			'function' => 'window.BroccoliFieldPx2I18nText'
		),
	),
	'html_attr_text'=>array(
		'backend'=>array(
			'class' => 'tomk79\\pickles2\\px2I18n\\fields\\html_attr_text',
			'require' => 'path/to/vendor/tomk79/px2-i18n/fields/i18n_html_attr_text/backend/html_attr_text.js',
		),
		'frontend'=>array(
			'dir' => 'path/to/vendor/tomk79/px2-i18n/fields/i18n_html_attr_text/frontend/',
			'file' => array(
				'html_attr_text.css',
				'html_attr_text.js'
			),
			'function' => 'window.BroccoliFieldPx2I18nHtmlAttrText'
		),
	),
	'multitext'=>array(
		'backend'=>array(
			'class' => 'tomk79\\pickles2\\px2I18n\\fields\\multitext',
			'require' => 'path/to/vendor/tomk79/px2-i18n/fields/i18n_multitext/backend/multitext.js',
		),
		'frontend'=>array(
			'dir' => 'path/to/vendor/tomk79/px2-i18n/fields/i18n_multitext/frontend/',
			'file' => array(
				'multitext.css',
				'multitext.js',
			),
			'function' => 'window.BroccoliFieldPx2I18nMultitext'
		),
	),
	'summernote'=>array(
		'backend'=>array(
			'class' => 'tomk79\\pickles2\\px2I18n\\fields\\summernote',
			'require' => 'path/to/vendor/tomk79/px2-i18n/fields/i18n_summernote/backend/summernote.js',
		),
		'frontend'=>array(
			'dir' => 'path/to/vendor/tomk79/px2-i18n/fields/i18n_summernote/frontend/',
			'file' => array(
				'summernote.css',
				'summernote.js',
				"summernote/summernote.min.css",
				"summernote/summernote.min.js",
			),
			'function' => 'window.BroccoliFieldPx2I18nSummernote'
		),
	),
);

/** Broccoliフィールドの初期設定 */
$mlSettings = array(
	'defaultLang' => $conf->default_lang,
	'subLangs' => $conf->accept_langs,
);

$conf->plugins->px2dt->guieditor->field_config = array(

	// text フィールドを設定
	'text' => $mlSettings,

	// html_attr_text フィールドを設定
	'html_attr_text' => $mlSettings,

	// multitext フィールドを設定
	'multitext' => $mlSettings,

	// summernote フィールドを設定
	'summernote' => $mlSettings,
);
```

#### Google Translation の認証情報を環境変数に宣言

[](#google-translation-の認証情報を環境変数に宣言)

```
// Google Cloud の認証情報のパスを、環境変数として宣言する
putenv( 'GOOGLE_APPLICATION_CREDENTIALS=/path/to/google-cloud-credentials.json' );
```

#### 多言語化されたページのパブリッシュ設定

[](#多言語化されたページのパブリッシュ設定)

各言語への対応を、デバイス別の出力設定として定義していきます。

```
$devices = array();
foreach( $conf->accept_langs as $langCode ){
	array_push( $devices, array(
		'user_agent'=>'Mozilla/',$langCode,
		'params' => array(
			'LANG' => $langCode,
		),
		'path_publish_dir'=>'../dist/',
		'path_rewrite_rule'=>'/'.$langCode.'{$dirname}/{$filename}.{$ext}',
		'paths_target'=>array(
			'/*',
		),
		'paths_ignore'=>array(
			// '/common/*',
		),

		// リンクの書き換え方向
		// `origin2origin`、`origin2rewrited`、`rewrited2origin`、`rewrited2rewrited` のいずれかで指定します。
		// `origin` は変換前のパス、 `rewrited` は変換後のパスを意味します。
		// 変換前のパスから変換後のパスへのリンクとして書き換える場合は `origin2rewrited` のように指定します。
		'rewrite_direction'=>'rewrited2rewrited',
	) );
}

/**
 * funcs: Before content
 *
 * サイトマップ読み込みの後、コンテンツ実行の前に実行するプラグインを設定します。
 */
$conf->funcs->before_content = array(
    // PX=api
    'picklesFramework2\commands\api::register' ,

    // PX=publish (px2-publish-ex)
    'tomk79\pickles2\publishEx\publish::register('.json_encode(array(
        'devices'=>$devices,
    )).')' ,

    // PX=px2dthelper
    'tomk79\pickles2\px2dthelper\main::register' ,
);
```

更新履歴 - Change log
-----------------

[](#更新履歴---change-log)

### tomk79/px2-i18n v0.1.0 (2023年2月11日)

[](#tomk79px2-i18n-v010-2023年2月11日)

- サポートするPHPのバージョンを `>=7.3.0` に変更。
- 編集画面を多言語対応(英語、中文、韓国語)した。
- より直接的な表現でプラグイン設定できるようになった。
- `langbank` のロード機能を追加した。

### tomk79/px2-i18n v0.0.1 (2021年7月18日)

[](#tomk79px2-i18n-v001-2021年7月18日)

- 初版リリース。

ライセンス - License
---------------

[](#ライセンス---license)

MIT License

作者 - Author
-----------

[](#作者---author)

- Tomoya Koyanagi
- website:
- Twitter: @tomk79

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~286 days

Total

3

Last Release

1184d ago

PHP version history (2 changes)0.0.1PHP &gt;=5.4.0

0.1.0PHP &gt;=7.3.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/00ca3b0b7c69b5a8c25bbfb82b305ab94c4fc7458b38df445cbb97acc073875f?d=identicon)[tomk79](/maintainers/tomk79)

---

Top Contributors

[![tomk79](https://avatars.githubusercontent.com/u/584845?v=4)](https://github.com/tomk79 "tomk79 (52 commits)")

---

Tags

pickles2

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/tomk79-px2-i18n/health.svg)

```
[![Health](https://phpackages.com/badges/tomk79-px2-i18n/health.svg)](https://phpackages.com/packages/tomk79-px2-i18n)
```

###  Alternatives

[tanmuhittin/laravel-google-translate

Translate translation files to other languages using google translate api

4312.2M11](/packages/tanmuhittin-laravel-google-translate)[boxblinkracer/phpunuhi

Easy tool to work with translation files for validation, exports, imports and more.

83225.2k17](/packages/boxblinkracer-phpunuhi)[om/potrans

Command line tool for translate Gettext with Google Translator API or DeepL API

10515.0k4](/packages/om-potrans)[acclaro/translations

Easily launch and manage multilingual Craft websites without having to copy/paste content or manually track updates.

1229.5k](/packages/acclaro-translations)[itsmattburgess/laravel-translate

Populate laravel translation files using services such as Google Translate

222.5k](/packages/itsmattburgess-laravel-translate)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
