Download the PHP package gossi/propel-l10n-behavior without Composer

On this page you can find all versions of the php package gossi/propel-l10n-behavior. 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 propel-l10n-behavior

Propel l10n Behavior

Build Status

The propel-l10n-behavior is an extension to propels own i18n behavior. Basically, it puts an API in front of the i18n behavior and let's you use propels default API but with localized content. You provide the localization you want to use once (globally) and you are ready to go.

Installation

Install via composer:

Locale and Dependencies

When working with locales, you should know about the locales and dependencies you can define for the propel-l10n-behavior. There are three mechanisms:

Set Default locale

Default locale is set to en but of course you can change this:

The default locale can be overwritten per object, e.g. you have a Book model, this is how it works:

Now, the locale for book is japanese, while for all others it stays german (as seen in the example above). You can reset this object-related overwrite by setting the locale to null:

The object default locale can be overwritten per call, e.g.

Set Fallback locale

Fallback locale also is defaulted to en, yet you can change that:

Working with Dependencies

There is some API to work with dependencies:

Retrieving a localized Field

Whenever you retrieve a localized field, the behavior will use the following algorithm to find the contents for the field in the most recent locale:

  1. Set default locale as locale.
  2. Try to get the field in the set locale
  3. If empty, check if the locale has a dependency and if yes a. if the primary language of the dependency and the current locale are different, work down the language-tag-chain of the current locale b. set dependency as new locale, continue with step 2
  4. If no dependecy is set for that locale, work down the language-tag-chain
  5. If primary language is empty, use fallback as new locale and continue with step 2
  6. Last step: giving up, return null

Language-tag-chain:

Given the following language-tag: de-DE-1996 it consists of three subtags. When working down the language-tag-chain it means, the last subtag is dropped and it will be tried to getting the content of a field for the remaining language-tag until there is only the primary language left.

Usage

In your schema.xml

The usage in your schema.xml is very similar to the i18n behavior.

The parameters are equal to the i18n parameters, except default_locale doesn't exist.

Using the API

There is three things you need to do once for your app and you are ready to go and use propel as if they weren't any l10n/i18n behaviors used at all.

  1. Set the default locale
  2. Set a fallback locale
  3. Set your dependencies

Example:

And you are ready to go.

Retrieving from Objects

Querying the Database

You can use your well known methods to query the database:

Best Practices

Use the shortest locale possible! Only use a longer language-tag, when it is necessary to be more specific. If there is no need, just go with de instead of de-DE (which is kind of redundant anyway). However, go with de and de-CH as there might be content available which is different for people in germany or switzerland (e.g. a contact address, one for germany the other for switzerland).

Performance

I'm pretty sure this is a performance nightmare. Only propel API methods are used, means no manual queries so far. Performance optimization can begin after propel will merge the data-mapper branch into master. Suggestions are welcome, please post the to the issue tracker.

References

There's a lot material about localization, language-tags. Sometimes it is about finding the right subtag, which can be complicated enough. Here are some good references:

Related Specifications:


All versions of propel-l10n-behavior with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4
ext-intl Version *
propel/propel Version ~2@dev
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 gossi/propel-l10n-behavior contains the following files

Loading the files please wait ....