DEV Community

Seth Phat
Seth Phat

Posted on

Laravel Multilingual Library

Hi Laravel Rockstars,

I have just finished recently my Laravel Package/Library. It's for multi-language purposes. Current version (1.0.0) is available now.

Main Ideas for v1.0.0

  • No need to touch the static language files in the project, manage it dynamically on backend pages - Lovely feature for Editors/Translators
  • Dealing with many languages as you want
  • Cache-able the language texts & retrieve it faster.
  • ...

Supported Laravel Versions

  • 6.x: Testing
  • 5.8: Tested - Supported
  • 5.7: Tested - Supported
  • 5.6: Testing
  • 5.5: Testing
  • 5.4: Testing

But I think from 5.5+, it should work fine. Not 100% sure, still testing 😂

Backend Page

Backend Page - Demo - Laravel Multilingual Seth Phat

APIs

Simply use this function:

/**
* Get the translation text
* @param string $textKey Key Value of Text Bundle Item - Required
* @param string $moduleName Text Bundle Name - Required
* @param array $replaceText Same as Laravel Translation to replace text (My name is :name => ['name' => 'Seth Phat']) - Default: array()
* @param string $specificLanguage Define the specific language to retrieve - Default: App::getLocale() - Current language
* @param boolean $should_throw Throw Exception when the text is not found or not. Default: false
*/
multilingual(string $textKey, string $moduleName, array $replaceText, string $specificLanguage, boolean $shouldThrow)
Enter fullscreen mode Exit fullscreen mode

To change language, just simply use the App::setLocale of Laravel.

Plans

  • Version 1.0.0: Static Language Text (Available now)
  • Version 1.1.0: Inject to specific Table/Entity for multilingual purpose. More APIs...

Install and Github

Main repository: GitHub - Laravel Multilingual

All the instruction of the installation is there. Check it out.

Thank you for reading! Any reviews/bug-report would help this library a lot :D. Give it a ⭐ if you like it 😍

Top comments (0)