Download the PHP package nabeghe/light-localization without Composer

On this page you can find all versions of the php package nabeghe/light-localization. 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 light-localization

Light Localization

A lightweight, key-value & path-based PHP localization library.
Translation groups are loaded lazily — only when first accessed.

Requirements

Installation

Directory Structure

Organize your translations like this:

Quick Start

Constructor

Parameter Description
$path Absolute path to the translations root directory
$locale Active locale code
$fallback Another Localizer to chain, or a plain string used as default
$defaultTranslationText Returned when no translation is found anywhere in the chain
$atlin Custom Atlin instance; created automatically if null

Translation Files

PHP

Return a plain associative array. Values can be strings or arrays of strings (for rnd()).

Atlin

Standard key-value .atlin format:

API Reference

Locale

Method Description
getLocale(): string Returns the current locale
setLocale(string $locale): void Changes the locale and clears all loaded groups
getLastLocale(): ?string Locale used in the most recent successful lookup

Lookup

Method Description
get(string $key, string $group = 'main', bool $deep = true): ?string Returns the translation for a key
rnd(string $key, string $group = 'main', bool $deep = true): ?string Like get(), but picks a random item when the value is an array
has(string $key, string $group = 'main', bool $deep = true): bool Checks whether a key exists

Group Management

Method Description
load(string $group): bool Loads a translation group from disk
refresh(): void Reloads all currently loaded groups
reset(): void Clears all loaded groups from memory
resetTranslation(string $group): bool Removes a specific group from memory
hasTranslation(string $group): bool Checks whether a group is loaded in memory
hasTranslationFile(string $group): bool Checks whether a group file exists on disk

Fallback & Default Text

Method Description
getFallback() Returns the current fallback (Localizer or string)
setFallback(Localizer\|string\|null $fallback): void Sets a new fallback
getDefaultTranslationText(): ?string Returns the static default text
setDefaultTranslationText(?string $text): void Sets the static default text

Fallback Chain

When a key is not found in the active locale, the library resolves it in this order:

  1. Current locale group (lazy-loaded from disk)
  2. Fallback Localizer (if provided), recursively
  3. Fallback string (if provided instead of a Localizer)
  4. defaultTranslationText (constructor parameter / setter)
  5. null

Running Tests

License

Licensed under the MIT License.


All versions of light-localization with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
nabeghe/atlin Version ^0.2.1
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 nabeghe/light-localization contains the following files

Loading the files please wait ...