Download the PHP package leanadmin/gloss without Composer

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

🔍 Gloss ✨ — Brilliant localization for Laravel

Gloss is a Laravel package for advanced localization.

Laravel's localization system is perfect for many languages, but it breaks down when you need a bit more control.

For example, some languages change words depending on the context they're used in. The words may get prefixed, suffixed, or even changed completely.

Aside from adding support for complex languages, Gloss also ships with quality of life improvements such as the ability to add formatting to a translation string.

Installation

Laravel 6 or 8 is required, PHP 7.4 is required.

Configuration

By default, Gloss comes with the gloss() helper and ___() helper.

If you wish, you may disable the ___() helper by setting:

And if you wish to make all existing __() calls Gloss-aware:

A good place for these calls is the boot() method of your LeanServiceProvider or AppServiceProvider.

Usage

Gloss can be used just like the standard Laravel localization helpers:

However, unlike the standard localization, it lets you make changes to these strings on the fly:

Value overrides

Imagine that you're editing the Order resource in an admin panel. Your resource's singular label is Objednávka, which is Czech for Order.

The language string for the create button is

If we fill the value with the resource name, we get Vytvořit Objednávka. Unfortunately, that's wrong not once, but twice.

Firstly, it should be Objednávku, because the suffix changes with context. And secondly, it's grammatically incorrect to capitalize the word here.

So we want to specify a complete override of that language string whenever we're in the Order resource context.

To do this, simply call:

(From an appropriate place, where the application is working with the Order resource.)

If you're using Lean, this is taken care of for you. You can simply define entire language strings in the $lang property of your resource, and they'll be used in all templates which use the resource.

Also note that the example above mentions resources, but that's just how Lean is implemented. Gloss will work with any setup.

You can also set multiple value overrides in a single call:

You may also use the gloss() helper for this. Simply pass the array as the first argument.

Scoping overrides

Sometimes you may want to scope your overrides. For example, rather than overriding all resource.create with Vytvořit objednávku, you may want to only do that if the resource parameter is order.

To do this, pass a third argument:

The condition can also be passed to values():

Or to the gloss() helper when setting overrides:

Key overrides

To build up on the example above, let's say our admin panel uses multiple languages. So replacing the language string with a translation that's part of the code isn't feasible.

For this reason, Gloss also lets you alias keys to another keys:

This is equivalent to fetching the value using a translation helper.

As with value(), you can pass conditions:

Extending values

You may also build upon fully resolved language strings.

For example, consider the following example:

To localize this, we'd either have to localize each word separately (which is what Laravel does, and it breaks down similarly to the "Order" word example), or we'd have to add the markup to the translation strings (which sucks for security, translator life quality), or we'd have to ditch the formatting completely.

All of those are unnecessary trade-offs.

Gloss lets you add formatting after the string is fully built:

Of course, extend() works perfectly with localized strings:

It even works with pluralized/choice-based strings:

The second argument is a callable that can return any string, but in most cases this will simply be the resolved string with a few segments replaced.

For that reason, Gloss automatically passes $replace to the callable, which lets you replace parts of the string using beautiful, arrow function-compatible syntax.

Callable translation strings

Gloss also adds support for callable translation strings.

Those can be useful when you have some code for dealing with things like inflection.

For example, consider these three language strings:

In many languages that have declension (inflection of nouns, read more about the complexities of localization on in our documentation), the form of :Resource will be the same for create, edit, and delete.

It would be painful to translate each string manually for no reason. A better solution is to use intelligent inflection logic as the default, while still keeping the option to manually change specific strings if needed.

You could have logic like this (with your own helpers) for the default values, and only use the overrides when some words are have irregular grammar rules and need custom values.


All versions of gloss with dependencies

PHP Build Version
Package Version
Requires illuminate/translation Version ^9.0|^10.0
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 leanadmin/gloss contains the following files

Loading the files please wait ....