8000 GitHub - shonhor22/Localisation: Laravel Enso Localisation package, meant to make it easy to build an application and offer it in multiple language versions
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Laravel Enso Localisation package, meant to make it easy to build an application and offer it in multiple language versions

License

Notifications You must be signed in to change notification settings

shonhor22/Localisation

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Localisation Manager

Codacy Badge StyleCI License Total Downloads Latest Stable Version

Localisation management dependency for Laravel Enso.

Screenshot

Watch the demo click on the photo to view a short demo in compatible browsers

Features

  • allows an easier management of languages, keys and translations in the context of a multi language application
  • uses the newer Laravel __() translation method and stores keys and translations inside a JSON file
  • permits adding as many languages as you require and the quick creation of translations for the keys you need
  • the language selector is easily accessible in the right-hand sidebar

Under the Hood

  • the languages table stores the available languages for localisation

    • name - the language code, e.g. 'en'
    • display_name - the label for the language, visible in the UI, e.g. 'English'
    • flag - the icon class used for showing the flag
  • when translating, the new Laravel mechanism is used, respectively the __() function

  • the main language is considered to be english

  • the keys are, by convention, in english and in a human readable format e.g. 'Date of Birth', and if a key is not found, the value of the key is used instead

  • the keys and the values for the keys are kept in resources/lang/*code*.json where code is the language code, e.g. 'de' for german, with the exception for the english language, since keys are already in english

  • due to Laravel's implementation, there are 4 translation categories which cannot be implemented using the new mechanism: auth, pagination, passwords, validation. For this reason, we keep the respective language files in their proper language sub-folders

  • the moment a new language is added from the interface

    • the new language is saved in the database
    • the four php translation files are copied to a newly created language folder
    • a new JSON language file is generated, containing the keys for the existing translations. The keys are collected using as reference the first existing JSON file
  • when deleting a language

    • the language is removed from the database
    • the language folder and its contents are removed
    • the JSON language file is removed
  • the set-language middleware is used to set the locale for the backend, for each request, depending on the user's language preference

  • the LanguagePolicy ensures that when deleting a language, a user cannot delete the default language, or the language he has currently set as active in his preferences

  • the list of languages and the translations are loaded on app init, so the changes will be available at the next login or at a page refresh

Usage Notes

Please note that because we want to keep the compiled size down, throughout the enso ecosistem, icons are imported selectively.

What this means for the localisation package, is that when adding a new language, you should also make sure you import the required flag icon SVG and declare the corresponding class. The proper place to include the new icon is:

resources/assets/sass/app.scss

Publishes

  • php artisan vendor:publish --tag=localisation-assets - the VueJS components and pages
  • php artisan vendor:publish --tag=enso-assets - a common alias for when wanting to update the VueJS assets, once a newer version is released, can be used with the --force flag

TO DO

  • sync-json command / button

Notes

The Laravel Enso Core package comes with this package included.

Depends on:

Contributions

are welcome. Pull requests are great, but issues are good too.

License

This package is released under the MIT license.

About

Laravel Enso Localisation package, meant to make it easy to build an application and offer it in multiple language versions

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 87.3%
  • Vue 11.1%
  • JavaScript 1.6%
0