Download the PHP package frmb/language without Composer

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

Language

Build Status Scrutinizer Code Quality Code Coverage

A PHP-class to render a specific language on the website depending on clients browser language for a multi-language website in Anax-MVC Framework: http://github.com/mosbth/Anax-MVC/

How to use

Installation

Install by using composer and enter the following code in your composer.json file:

You can also clone this repository and install it manually in your Anax-MVC project.

Once the files have been downloaded create a new folder in your Anax app/content directory called Language, this is where the XML files will be placed.

If you want to test the example included, copy the files from vendor/frmb/language/content/Language to your Language file created above and copy the LanguageTest.php file from the webroot directory to yours and you're ready to go!

Usage

To load the Language Module you need to create a new Shared variable using this code in your Front Controller

Then you're ready to begin.

Basics

Configuration

Open up tile class file Language.php inside the installation directory (default vendor/frmb/language/src/Language/), inside the __construct function there's block of configuration. There you will set what languages that the site will support, en (English) should always be included as it's default for unsupported languages. Then whatever language you insert is up to you for example: sv (Swedish), dk (Denmark) and no (Norwegian), do remember that if you enter a language in the configuration, you MUST create a file matching the language.

To create new Language files use this template and call it prefix_board.xml where prefix is the language, for example en or sv inside the content/Language folder and paste this XML

Having the Verbose option set to true is highly recommended during the development and testing period as you'll be able to see what files are being loaded and not. Verbose can also be toggled by writing ?verbose in the browser.

General

The default file that's loaded when inside a Front Controller is the prefix_board.xml file where prefix is the selected language by the browser and automatically detected by Language (or manually by entering ?l=SHORT_LANGUAGE in the browser), this is where all global words and sentences should be saved, such as credits, welcome message, footer messages and so on.

The class can accessed inside your Front Controller by typing

This will generate the text from prefix_board.xml which is "Welcome to my module!" or any other language that you have set and translated.

To use the it inside a Controller or a Module class you will simply call the Words function by using $this instead of $app for example:

But if we call the Language class inside a Controller or Module then we're no longer inside the "board", right? We're inside the Controller or Module and therefore we need a new XML document to cover its words! As default you need to create a new file in your Language folder called prefix_classname.xml, in the example above the result would be en_commentcontroller.xml. You can simply paste the xml code that's in the Configuration a little bit up, but if you watch closely there's a xml object called "word_app" where it says "board", yet again, we're not in the board but in a Controller or a Module now, so change it to our class name, CommentController as in the exampel.

That should cover the most basic usage, more in Advanced usage!

Advanced Usage

Lets continue on handling external Controllers like the example CommentController which I mentionened above. Sometimes you do not call a Controller or Module directly inside the Front Controller but still want to use the words for a Controller like our CommentController to write out a title or a sentence before it's been called.
You can pre-load the controller file by passing the parameter "module" inside the Words function:

Now the CommentControllers xml file would have been loaded and is available for usage.

This can be useful for other things than only pre-loading controllers, we can for example create a dynamic navbar

Using the example above would require a new file called prefix_navbar.xml with the word_app set to navbar.

Forcing a language to be used is also possible, we can for example always make one set as English by using the parameter lang.

Changelog

2015-03-14 1.2 - Added Travis CI and Scrutinizer. Optimized code and added 4 more test cases for PHPUnit.
2015-03-14 1.1 - Many updates
2015-03-08 1.0 - Initial release


All versions of language with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4
anax/mvc Version dev-master
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 frmb/language contains the following files

Loading the files please wait ....