Android: Get missing translations for strings-resources
Date : March 29 2020, 07:55 AM
will be helpful for those in need Interesting question. I've wrote simple script to find duplicate resources in android project at https://gist.github.com/1133059. It is ugly, I know, but I'll rewrite it in a few days and maybe create a project on github. To run it from console: $scala DuplicatesFinder.scala /path/to/android/project
|
Android: translations in resources
Tag : java , By : deanschang
Date : March 29 2020, 07:55 AM
Any of those help correct suffixes for Chinese and Spanish are "-zh" and "-es" ps. and German is "-de", just in case you might need it later.
|
Django translations block not translated
Tag : django , By : user150744
Date : March 29 2020, 07:55 AM
|
Laravel 5.2 Eloquent - how to automatically fetch translated content using separate translations table
Date : March 29 2020, 07:55 AM
hope this fix your issue The solution that finally did the trick was to use an Eloquent Event. I did indeed create a custom base model class that extends the Eloquent\Model, and what I did was to register a new Eloquent Event to it, called "loaded", which is triggered right after a model instance is created. So now the result can be manipulated accordingly, and returned to our application already translated. This is my custom base model, where I am registering the custom "loaded" event: <?php
//app/CustomBaseModel.php
namespace App;
use Illuminate\Database\Eloquent\Model;
abstract class CustomBaseModel extends Model
{
/**
* Register a loaded model event with the dispatcher.
*
* @param \Closure|string $callback
* @return void
*/
public static function loaded($callback)
{
static::registerModelEvent('loaded', $callback);
}
/**
* Get the observable event names.
*
* @return array
*/
public function getObservableEvents()
{
return array_merge(parent::getObservableEvents(), array('loaded'));
}
/**
* Create a new model instance that is existing.
*
* @param array $attributes
* @param $connection
* @return \Illuminate\Database\Eloquent\Model|static
*/
public function newFromBuilder($attributes = array(), $connection = NULL)
{
$instance = parent::newFromBuilder($attributes);
$instance->fireModelEvent('loaded', false);
return $instance;
}
}//end class
<?php
//app/Providers/TranslationServiceProvider.php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Contracts\Events\Dispatcher as DispatcherContract;
class TranslationServiceProvider extends ServiceProvider
{
/**
* Bootstrap the application services.
*
* @return void
*/
public function boot(DispatcherContract $events)
{
$events->listen('eloquent.loaded: *', function ($ourModelInstance) { // "*" is a wildcard matching all models, replace if you need to apply to only one model, for example "App\Article"
//translation code goes here
$ourModelInstance->translate(); //example
}, 0);
}
/**
* Register the application services.
*
* @return void
*/
public function register()
{
//
}
}
<?php
//config/app.php
...
'providers' => [
...
/*
* Custom Service Providers...
*/
App\Providers\TranslationServiceProvider::class,
],
...
<?php
//app/Article.php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Article extends CustomBaseModel
{
//
}
|
Tag : php , By : user87752
Date : March 29 2020, 07:55 AM
I hope this helps you . On my Symfony 3.2 project I extended the FosUserBundle's on a file named messages.en.yml that has the following content: {% trans_default_domain 'FOSUserBundle' %}
|