Download the PHP package alnaggar/muhawil without Composer

On this page you can find all versions of the php package alnaggar/muhawil. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package muhawil

Muhawil - PHP Package For Loading And Dumping Translations

Muhawil is a PHP package designed to simplify the process of loading and dumping translations. The name 'Muhawil' is derived from the Arabic word "مُحَوِّل", meaning transformer or adapter, as it facilitates reading and writing translations in several formats.

The package natively supports 6 file types:

Additionally, you can create your own custom loaders and dumpers.

Requirements

Installation

Install the package using Composer:

Loading Translations

All files loaders extend the Alnaggar\Muhawil\Loaders\FileLoader abstract class, which provides the load (string $path) method to load the transaltions from the specified file.

Handling Missing Translation Values

The FileLoader class uses the Alnaggar\Muhawil\Traits\HasMissingTranslationValueHandler trait. By default, if a translation value is missing (empty or null), the translation key itself is returned. This makes missing translations are visibly flagged in the UI for correction.

To override this behavior, pass a callback to setMissingTranslationValueCallback() which receives:

The callback function is responsible for determining and returning the appropriate value.

Dumping Translations

All file dumpers extend the Alnaggar\Muhawil\Dumpers\FileDumper abstract class, and each has its own dump() method signature as described in each section below.

JSON

Load JSON translations using Alnaggar\Muhawil\Loaders\JsonFileLoader class.

Dump JSON translations using Alnaggar\Muhawil\Dumpers\JsonFileDumper class, using its dump(array $translations, string $path, int $flags = JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT): static method.

MO

Load MO translations using Alnaggar\Muhawil\Loaders\MoFileLoader class.

Dump MO translations using Alnaggar\Muhawil\Dumpers\MoFileDumper class, using its dump(array $translations, string $path, array $metadata = []): static method.

The dumper uses the Alnaggar\Muhawil\Traits\HasPluralForms trait, to automatically generates the Plural-Forms metadata if the Language metadata is provided and Plural-Forms is not explicitly set.

Both The MO loader and dumper constructors accept two optional parameters:

PHP

Load PHP translations using Alnaggar\Muhawil\Loaders\PhpFileLoader class.

Dump PHP translations using Alnaggar\Muhawil\Dumpers\PhpFileDumper class, using its dump(array $translations, string $path): static method.

PO

Load PO translations using Alnaggar\Muhawil\Loaders\PoFileLoader class.

Dump PO translations using Alnaggar\Muhawil\Dumpers\PoFileDumper class, using its dump(array $translations, string $path, array $metadata = []): static method.

The dumper uses the Alnaggar\Muhawil\Traits\HasPluralForms trait, to automatically generates the Plural-Forms metadata if the Language metadata is provided and Plural-Forms is not explicitly set.

Both The PO loader and dumper constructors accept two optional parameters:

XLIFF

Load XLIFF translations using Alnaggar\Muhawil\Loaders\XliffFileLoader class.

Dump XLIFF translations using Alnaggar\Muhawil\Dumpers\XliffFileDumper class, using its dump(array $translations, string $path, string $sourceLocale = 'en', string $targetLocale = 'en', bool $legacy = false, string $fileId = 'f1'): static method.

YAML

Load YAML translations using Alnaggar\Muhawil\Loaders\YamlFileLoader class.

Dump YAML translations using Alnaggar\Muhawil\Dumpers\YamlFileDumper class, using its dump(array $translations, string $path, bool $dry = true): static method.

Both the YAML loader and dumper support only simple YAML structures, including mappings, nested mappings, and scalar values. Keys and scalar values may be double-quoted, single-quoted, or unquoted (as long as they do not contain special YAML characters).

Custom Loaders and Dumpers

You can implement your own loaders and dumpers for any type of storage, like a database or any other storage, by implementing the Alnaggar\Muhawil\Interfaces\Loader and Alnaggar\Muhawil\Interfaces\Dumper interfaces and their respective load and dump methods.

For example, to create a custom loader for a database, you would create a class that implements the Loader interface and define the load method to fetch translations from the database. Similarly, for a custom dumper, implement the Dumper interface and define the dump method to save translations back to the database.

This flexibility allows you to tailor Muhawil to your specific needs beyond the provided file-based loaders and dumpers.

Contributing

If you find any issues or have suggestions for improvements, feel free to open an issue or submit a pull request on the GitHub repository.

Credits

License

Muhawil is open-sourced software licensed under the MIT license.


All versions of muhawil with dependencies

PHP Build Version
Package Version
Requires php Version >=7.3
ext-json Version *
ext-pcre Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package alnaggar/muhawil contains the following files

Loading the files please wait ....