Comments (6)
might want to ask you first, what version did you use of this package?
from laravel-gettext.
Sorry, I use 1.1.0.
from laravel-gettext.
Whoops, sorry. It should be fixed on 1.1.1
well if you change locale in app.php
,
to change language you can use e.g.
set_locale(LC_ALL, \Config::get('app.locale'));
from laravel-gettext.
It's alright :)
Seems to be working now, except that I don't get the Swedish language to be loaded.
I have translated all the strings and saved it, tried restarting Apache for caching issues. But no luck.
Any ideas? :)
from laravel-gettext.
I tried some sample
- create view on:
resources/views/test.blade.php
{!! _('We have e-mailed your password reset link!') !!}
-
run
php artisan vendor:publish
to publish the config -
add some locale in
config/gettext.php
in languages array
'languages' => [
'en' => [
'locale' => 'en_US',
'encoding' => 'utf-8',
'plural_forms' => "nplurals=2; plural=(n != 1);",
],
'sv' => [
'locale' => 'sv_SE', // usually use IDLanguage_IDCountry format like suggested in phptal.org/manual/en/split/gettext.html
'encoding' => 'utf-8',
'plural_forms' => "nplurals=2; plural=(n != 1);",
],
],
- run
php artisan gettext:create --sources="resources\views"
. This will generate .po files in
resources\locale\en_US\LC_MESSAGES\messages.po
resources\locale\sv_SE\LC_MESSAGES\messages.po
& scan files on resources/views directory.
-
I usually edit .po files using PoEdit (clicking update, start translating, and save). It will generate .mo file in the same place.
-
simple test in my route
Route::get('lang/{id}', function($id) {
$lang = Config::get('gettext.languages.'.$id);
set_locale(LC_ALL, $lang['locale'].'.'.$lang['encoding']); // e.g. sv_SE.utf-8
bindtextdomain('messages', base_path('resources/locale')); // locate to correct path
textdomain('messages'); // set default domain
return view('test');
});
This test is on WINDOWS machine. Should be working on UNIX also since Unit Test passing on travis.
from laravel-gettext.
Thank you very much!
I really appreciate your help. For a newbie like me, it's not really obvious to set bindtextdomain and textdomain, didn't even realize set_locale existed before I looked in your tests. :)
It would be nice to add these explanations to the readme file.
Good work!
from laravel-gettext.
Related Issues (4)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-gettext.