All Projects → stevegrunwell → lost-in-translation

stevegrunwell / lost-in-translation

Licence: MIT license
Uncover missing translations and localization strings in Laravel applications.

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to lost-in-translation

React Translated
A dead simple way to add complex translations (i18n) in a React (DOM/Native) project 🌎🌍🌏
Stars: ✭ 176 (+450%)
Mutual labels:  translation, localization
Weblate
Web based localization tool with tight version control integration.
Stars: ✭ 2,719 (+8396.88%)
Mutual labels:  translation, localization
Hangulize
Korean Alphabet Transcription
Stars: ✭ 184 (+475%)
Mutual labels:  translation, localization
Formatjs
The monorepo home to all of the FormatJS related libraries, most notably react-intl.
Stars: ✭ 12,869 (+40115.63%)
Mutual labels:  translation, localization
Localisation
Repository for translation and discussion for OpenRCT2.
Stars: ✭ 49 (+53.13%)
Mutual labels:  translation, localization
Es2015 I18n Tag
ES2015 template literal tag for i18n and l10n (translation and internationalization)
Stars: ✭ 171 (+434.38%)
Mutual labels:  translation, localization
Laravel Localization Helpers
🎌 Artisan commands to generate and update lang files automatically
Stars: ✭ 190 (+493.75%)
Mutual labels:  translation, laravel-package
Roenglishre
An unofficial english translation project for Korea Ragnarok Online (kRO).
Stars: ✭ 121 (+278.13%)
Mutual labels:  translation, localization
Counterpart
A translation and localization library for Node.js and the browser.
Stars: ✭ 239 (+646.88%)
Mutual labels:  translation, localization
Languagetest
Changing the language on Android
Stars: ✭ 223 (+596.88%)
Mutual labels:  translation, localization
I18n Extract
Manage localization with static analysis. 🔍
Stars: ✭ 152 (+375%)
Mutual labels:  translation, localization
mobility-actiontext
Translate Rails Action Text rich text with Mobility.
Stars: ✭ 27 (-15.62%)
Mutual labels:  translation, localization
Punic
PHP translation and localization made easy!
Stars: ✭ 133 (+315.63%)
Mutual labels:  translation, localization
Node Gettext
A JavaScript implementation of gettext, a localization framework.
Stars: ✭ 175 (+446.88%)
Mutual labels:  translation, localization
Dom I18n
Provides a very basic HTML multilingual support using JavaScript
Stars: ✭ 125 (+290.63%)
Mutual labels:  translation, localization
Linguist
Easy multilingual urls and redirection support for the Laravel framework
Stars: ✭ 188 (+487.5%)
Mutual labels:  translation, localization
Phabricator zh hans
Phabricator zh-Hans Translation & Tools.
Stars: ✭ 113 (+253.13%)
Mutual labels:  translation, localization
React I18nify
Simple i18n translation and localization components and helpers for React.
Stars: ✭ 123 (+284.38%)
Mutual labels:  translation, localization
Omegat
Mirror of official OmegaT repo
Stars: ✭ 210 (+556.25%)
Mutual labels:  translation, localization
Translation Sheet
Translating Laravel languages files using a Google Spreadsheet.
Stars: ✭ 254 (+693.75%)
Mutual labels:  translation, laravel-package

Lost in Translation

Build Status Coverage Status

Lost in Translation is designed to help developers locate instances of localization strings within a Laravel application that haven't been provided translations.

Installation

Lost in Translation can be installed into your Laravel project via Composer:

$ composer require stevegrunwell/lost-in-translation

By default, this will replace the default TranslationServiceProvider class with a sub-class that adds additional logic when a translation isn't found. To resume default behavior (even in a production environment), see the "Configuration" section below.

Configuration

By default, Lost in Translation will catch missing translations in two ways:

  1. In environments where APP_DEBUG is true, a LostInTranslation\MissingTranslationException will be found if the application attempts to load a translation that hasn't been defined.
  2. Missing translations will be written to storage/logs/lost-in-translation.log.

Either of these can be disabled via the package's configuration, making Lost in Translation safe to use in production. These values can be set using the following environment variables:

TRANS_LOG_MISSING
Determines whether or not missing translations should be logged. Default is "true".
TRANS_ERROR_ON_MISSING
Should MissingTranslationException exceptions be thrown when a translation is missing? Default is "false".

To override package configuration, run the following to copy the configuration to your app's config/ directory:

$ php artisan vendor:publish --provider="LostInTranslation\Providers\TranslationServiceProvider"

This will create a new file in config/lostintranslation.php, where default values for your application can be set.

Extending

When a missing translation is found, the a LostInTranslation\MissingTranslationFound event will be dispatched. This event makes it easy to do something (send an email, open a GitHub issue, etc.)when a missing translation is encountered.

First, create a new event listener in your application; in this example, we're using app/Listeners/NotifyOfMissingTranslation.php:

<?php

namespace App\Listeners;

use LostInTranslation\Events\MissingTranslationFound;

class NotifyOfMissingTranslation
{
    /**
     * Handle the event.
     *
     * @param MissingTranslationFound $event
     *
     * @return void
     */
    public function handle(MissingTranslationFound $event)
    {
        // Do something with the event.
    }
}

The MissingTranslationFound event has four public properties of note:

  1. $key - The translation key that was not found.
  2. $replacements - Any replacements that were passed to the translation call.
  3. $locale - The locale that was being used.
  4. $fallback - The fallback locale, if defined.

Then, in app/Providers/EventServiceProvider.php, add the following to register NotifyOfMissingTranslation as a callback when a MissingTranslationFound event occurs:

/**
 * The event listener mappings for the application.
 *
 * @var array
 */
protected $listen = [
    'LostInTranslation\Events\MissingTranslationFound' => [
        'App\Listeners\NotifyOfMissingTranslation',
    ],
];

For more on event listeners, please see the Laravel Events documentation.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].