| 1 |
# Internationalization |
| 2 |
|
| 3 |
[](https://bracketspace.com](https://bracketspace.com](https://bracketspace.com) |
| 4 |
[](https://packagist.org/packages/micropackage/internationalization](https://packagist.org/packages/micropackage/internationalization](https://packagist.org/packages/micropackage/internationalization) |
| 5 |
[](https://packagist.org/packages/micropackage/internationalization](https://packagist.org/packages/micropackage/internationalization](https://packagist.org/packages/micropackage/internationalization) |
| 6 |
[](https://packagist.org/packages/micropackage/internationalization](https://packagist.org/packages/micropackage/internationalization](https://packagist.org/packages/micropackage/internationalization) |
| 7 |
[](https://packagist.org/packages/micropackage/internationalization](https://packagist.org/packages/micropackage/internationalization](https://packagist.org/packages/micropackage/internationalization) |
| 8 |
|
| 9 |
<p align="center"> |
| 10 |
<img src="https://bracketspace.com/extras/micropackage/micropackage-small.png" alt="Micropackage logo"/> |
| 11 |
</p> |
| 12 |
|
| 13 |
## 🧬 About Internationalization |
| 14 |
|
| 15 |
The Internationalization micropackage is an unified wrapper for both `load_plugin_textdomain` and `load_theme_textdomain` functions. |
| 16 |
|
| 17 |
It can handle both theme and plugin language packs but also any other 3rd party library, like a translated Composer package. |
| 18 |
|
| 19 |
The language file must follow the scheme: `{textdomain}-{locale_LOCALE}.mo`. |
| 20 |
|
| 21 |
This package is compatible with [](https://github.com/micropackage/dochooksDocHooks library](https://github.com/micropackage/dochooks](https://github.com/micropackage/dochooks). |
| 22 |
|
| 23 |
## 💾 Installation |
| 24 |
|
| 25 |
``` bash |
| 26 |
composer require micropackage/internationalization |
| 27 |
``` |
| 28 |
|
| 29 |
## 🕹 Usage |
| 30 |
|
| 31 |
Call the action manually: |
| 32 |
|
| 33 |
```php |
| 34 |
use Micropackage\Internationalization\Internationalization; |
| 35 |
|
| 36 |
add_action( 'init', [ new Internationalization( $textdomain, $full_language_dir_path ), 'load_translation' ] ); |
| 37 |
``` |
| 38 |
|
| 39 |
Using [](https://github.com/micropackage/dochooksDocHooks library](https://github.com/micropackage/dochooks](https://github.com/micropackage/dochooks): |
| 40 |
|
| 41 |
```php |
| 42 |
Micropackage\DocHooks\Helper::hook( new Internationalization( $textdomain, $full_language_dir_path ) ); |
| 43 |
``` |
| 44 |
|
| 45 |
Retrieving full path to the directory: |
| 46 |
|
| 47 |
```php |
| 48 |
$theme_language_dir = get_template_directory() . '/languages'; |
| 49 |
$plugin_language_dir = plugin_dir_path( __FILE__ ); |
| 50 |
``` |
| 51 |
|
| 52 |
## 📦 About the Micropackage project |
| 53 |
|
| 54 |
Micropackages - as the name suggests - are micro packages with a tiny bit of reusable code, helpful particularly in WordPress development. |
| 55 |
|
| 56 |
The aim is to have multiple packages which can be put together to create something bigger by defining only the structure. |
| 57 |
|
| 58 |
Micropackages are maintained by [](https://bracketspace.comBracketSpace](https://bracketspace.com](https://bracketspace.com). |
| 59 |
|
| 60 |
## 📖 Changelog |
| 61 |
|
| 62 |
[](./CHANGELOG.mdSee the changelog file](./CHANGELOG.md](./CHANGELOG.md). |
| 63 |
|
| 64 |
## 📃 License |
| 65 |
|
| 66 |
This software is released under MIT license. See the [](./LICENSELICENSE](./LICENSE](./LICENSE) file for more information. |
| 67 |
|