01 logo

Laravel vs FuelPHP Framework Comparision

This is our closing article on PHP internationalization systems and i18n prep instructional exercises. Our past articles take care of the accompanying viewpoints

By Tina ModiPublished about a year ago 4 min read
Like

Systems of internationalization with PHP by and large, with short neglect on the historical backdrop of i18n with PHP

PHP internationalization with GNU gettext

Internationalization How-Tos for the five most utilized PHP frameworks(CodeIgniter, CakePHP, Zend, Yii, and Symfony)

The last article in this series on PHP assimilation will cover two more PHP structures that are oftentimes utilized: Laravel and FuelPHP. On account of past analysts that have communicated revenue in covering Laravel in more detail.

PHP internationalization structures: The Laravel system

Internationalization in the Laravel structure should be possible by the utilization of the PHP cluster records, put away inside the application/lang catalog. Language documents for every language ought to be put away in their subdirectory:

/app /lang /en days.php months.php /de days.php months.php /fr days.php months.php

The language documents ought to return a variety of keyed strings: http://gist.github.com/bosskovic/6113848

The keys ought to be selected cautiously since, supposing that the language line for the dynamic language doesn't exist, the key will be returned. Laravel doesn't permit indicating a backup language.

The default language can be set in the application/config/app.php, and the dynamic language can be changed utilizing the App::setLocale strategy like this:

App::setLocale('de');

The lines can be recovered from the language records with the getting strategy for the Lang class. The contention passed to the getting strategy comprises two portions, the first being the name of the language record, and the second one the key of the line that ought to be recovered.

echo Lang::get('days.monday');

The presence of the interpretation for the particular key and dynamic language can be checked with the has technique:

if (Lang::has('days.monday')){ // }

Place-holders can be characterized in the language records, and subbed with the powerful qualities during the run time:

//messages.php 'Welcome, :username' ); ?>

The substitute qualities are passed to the getting technique in an exhibit as a subsequent contention:

reverberation Lang::get('messages.welcome', array('username' => $username));

A solitary structure can be isolated from a plural structure in the interpretations by the utilization of the "pipe" character:

'There is one apple|There are many apples' ); ?>

The Lang::choice strategy can be utilized to recover the line:

echo Lang::choice('messages.apples', 10);

Laravel interpreter is fueled by the Symfony Interpretation part, so more express pluralization rules can undoubtedly be made:

'{0} There are none|\[1,19\] There are some|\[20,Inf\] There are many' ); ?>

Create. Keep up with it. Streamline. Convey

Are you searching to hire dedicated web developer to construct exceptionally advanced web development? Reach out to PHPDots technologies to hire dedicated laravel developers.

PHP internationalization systems: The FuelPHP structure

The Lang class of the FuelPHP system permits setting up language factors utilizing language records. The default language (en) is set in application/config/config.php. The Config: set strategy can be utilized to change that worth:

Config::set('language', 'de');

FuelPHP likewise permits characterizing of fall-back language in the design, which is either a language code or a variety of language codes.

An illustration of application/config/config.php: https://gist.github.com/bosskovic/6116266\\

A few asset document designs are upheld by FuelPHP:

PHP exhibit records are the default type. They have a comparative key-esteem structure as recently depicted for the Laravel system.

INI documents. We take care of currently this asset document type in its very own article.

YAML documents. We take care of these also, you can track down the article here.

JSON records. You can learn about reason documents, and JSON asset records utilized in the Windows applications produced for Windows 8 in this article.

The language asset documents are stacked with the heap strategy for the Lang class. On the off chance that the asset document type isn't determined, Lang::load will default to the "php exhibit" type.

Explicit lines are recovered from the language record with the Lang::get strategy. The one required boundary of the getting technique is the key of the expression that ought to be returned. Discretionary boundaries are $parameters - a variety of boundaries used to supplant the spot holders, $default - worth to return on the off chance that the key can not be found and $language - language code for which the line ought to be recovered; on the off chance that not given, the presently dynamic language is utilized.

For different strategies for the Lang class, you can take a look at the authority FuelPHP documentation.

Model: [gist]https://gist.github.com/bosskovic/6116466\[/gist\]

This closes our series of articles on the PHP i18n. It ought to provide you with a thought of how site internationalization is executed across the PHP world and assist you with making the essential advances so your sites can be more open to a more extensive crowd. When that is clear, prepare for limitations. Converse with us if we can assist you with planning to carry out your applications in numerous dialects.

tech news
Like

About the Creator

Tina Modi

Laravel Developer at PHPDots Technologies

Reader insights

Be the first to share your insights about this piece.

How does it work?

Add your insights

Comments

There are no comments for this story

Be the first to respond and start the conversation.

Sign in to comment

    Find us on social media

    Miscellaneous links

    • Explore
    • Contact
    • Privacy Policy
    • Terms of Use
    • Support

    © 2024 Creatd, Inc. All Rights Reserved.