2017 © Pedro PelĂĄez
 

library felicity-translate

Translation functionality for PHP

image

felicity-php/felicity-translate

Translation functionality for PHP

  • Wednesday, November 29, 2017
  • by felicity-php
  • Repository
  • 1 Watchers
  • 0 Stars
  • 12 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

About Felicity Translate

Felicity translate provides a way to set and get translations in PHP, (*1)

Usage

Set your locale, default locale, and translations with Felicity Config and then use the translation class to get your translations., (*2)

<?php

use felicity\config\Config;
use felicity\translate\Translate;

Config::set('lang.defaultLocale', 'en');
Config::set('lang.locale', 'de');

Config::set('lang.translations.en.myCategory', [
    'myTranslationKey' => 'Translation of something',
    'anotherTranslationKey' => 'Translation of something with {{var}}',
]);

Config::set('lang.translations.de.myCategory', [
    'myTranslationKey' => 'Übersetzung von etwas',
    'anotherTranslationKey' => 'Übersetzung von etwas mit {{var}}',
]);

$myTranslation = Translate::get('myCategory', 'myTranslationKey');
$anotherTranslation = Translate::get('myCategory', 'anotherTranslationKey', [
    '{{var}}' => 'someVal',
]);

Usage in Felicity Twig

If you have required Felicity Twig into your project, you can use translations in twig as follows:, (*3)

{# As a function #}
{{ translate('myTranslation', 'optionalCategory') }}

{# As a filter #}
{{ 'myTranslation'|translate('optionalCategory') }}

If you do not provide a category, the default will be used, which is dev unless you set a default with Felicity Config:, (*4)

<?php

use felicity\config\Config;

Config::set('lang.defaultTwigCategory', 'myCategory');

License

Copyright 2017 BuzzingPixel, LLC, (*5)

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0., (*6)

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License., (*7)

The Versions

29/11 2017

dev-master

9999999-dev

Translation functionality for PHP

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

29/11 2017

1.1.0

1.1.0.0

Translation functionality for PHP

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

28/11 2017

1.0.1

1.0.1.0

Translation functionality for PHP

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

28/11 2017

1.0.0

1.0.0.0

Translation functionality for PHP

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires