rainlab / translate-plugin Goto Github PK
View Code? Open in Web Editor NEWEnables multi-lingual sites
License: Other
Enables multi-lingual sites
License: Other
Currently the new repeater widget form fields cannot be translated. It would be nice to have this feature.
It's very important to translate page title, makes no sense to change the language and keep page title in another language.
I've created a page with translated content block and also translated strings. Translation works fine with default language switcher component, but it doesn't react on url prefix changing.
I've also intsalled MenuManager plugin by Ben Freke and Breadcrumbs by Jared Meyering.
October CMS build is 134 and Translate plugin version is 1.0.2.
It is possible to translate strings in component's template file (components/xxx/default.htm) ?
Method what works in controller's htm files
<?= e(trans('cms::lang.component.no_records')) ?>
doesn't work in components.
It is excessively to add markup tag to each plugin which requires translation:
'translate' => function ($id, array $parameters = []) { return trans($id, $parameters); }
Hello. How i can translate page meta title ?
I have site with two languages, english (default) and german. I translated my Model class properties in backend from english to german and leave some of them blank. After I get record from database it has auto translated properties, but some of them are blank, because I did not fill them in backend.
It will be a good idea to fallback to default locale for those properties that are not translated. It is a better experience for user to see english value than an empty string.
In documentation is written:
I think, if you have multilingual site, it is better that you always redirected to /language when you come to root. Joomla have the same option. Why?
Is it possible to make this as an option, that you are always redirected?
So when user come to root, it checks:
Thanks in advance,
vizo
I have found this issue:
I have 2 langs configured, Russian as default and English.
If you go for example to site.com/en/about , then go directly to site.com/about locale will not be changed to default. Thats because of this code in routes.php:
$locale = Request::segment(1);
if ($translator->setLocale($locale)) {
Route::group(['prefix' => $locale], function() use ($locale) {
Route::any('{slug}', 'Cms\Classes\Controller@run')->where('slug', '(.*)?');
});
Route::any($locale, 'Cms\Classes\Controller@run');
}
setLocale will store locale in session, then later in Plugin.php locale will be loaded from session for translation. But going to site.com/about will not change locale in session since no locale specified in url and setLocale will fail.
This can be fixed with adding else:
$locale = Request::segment(1);
if ($translator->setLocale($locale)) {
Route::group(['prefix' => $locale], function() use ($locale) {
Route::any('{slug}', 'Cms\Classes\Controller@run')->where('slug', '(.*)?');
});
Route::any($locale, 'Cms\Classes\Controller@run');
} else $translator->setLocale($translator->getDefaultLocale());
I installed User plugin and Translate Plugin.
I used Translate Plugin to translate Countries and States in User plugin. There is no problem with translating Country Model, but something is wrong with translating State Model.
I added these lines in Country and State Models:
public $implement = ['RainLab.Translate.Behaviors.TranslatableModel'];
public $translatable = ['name'];
Next I went to Settings -> Locations in admin panel area. Inputs were changed dynamically by Translate Plugin. I translated Country record and so far everything is working fine. Next I tried to translate State, but translated state is not persisted to database. I checked $_POST variable and translation is sended. I debuged TranslatableModel.php and found that $translatableAttributes variable is empty in function syncTranslatableAttributes().
I quick fixed that by going through $_POST variable setting $translatableAttributes for RainLab\User\Models\State model in syncTranslatableAttributes() function.
That is very poor solution, but I have not found any other for this.
The problem persist everywhere where You use relationRender() function in backend view.
Sorry for my poor english. If you have questions I will try to help.
The plugin does not get the correct filename on line 51 of Plugin.php when a name without extention is passed. the function substr_replace returns a wrong file name like .enintrotext for a content named introtext.htm
Hi,
I have installed the plugin, and working on an improvement for pages plugins (see issue #32). I have tried the RainLab.Translate.Behaviors.TranslatableModel
behavior, but the class dosen't seem to exsist.
I have created a sample page, with this as code;
function onStart(){
if (!class_exists('RainLab\Translate\Behaviors\TranslatableModel'))
return;
else{
die('Class dosen\'t exsist!!');
}
}
And the result : Class dosen't exsist!!
.
Seem weird.
Thanks
With model translation at time of creating record it not saved with all languages it only save default language content, at time of updating record it save records with all languages.
i have extends translation model with my plugin and when i create record with all languages it`s not save other languages record, i have also check with forum plugin i got same result while creating(not updating) channel with all languages its only save data for default language not for other languages.
it should be like when you create record with all languages its save content for all languages.
To reproduce this issue go to october.dev/backend/rainlab/translate/messages
On this page it is not possible to scroll the left menu with the mouse scroll bar. (However, clicking the small bar and do the scrolling via drag & drop works)
I am experiencing this error in the current Chrome browser.
Currently, translations do not work in Popups/Modals. Screenshot: https://www.dropbox.com/s/13lo069zldzkmqx/Screenshot%202014-08-23%2015.36.34.png?dl=0
The POST-data looks correct, it includes the translation strings. Also, the TranslatableModel::setTranslateAttribute() function is called accordingly. However, in the syncTranslatableAttributes()-method the $translateableAttributes array is empty (empty array).
My guess is, the model / model behaviour is re -instanciated somewhere in the application. It may be related to the way october saves related models, but I couldnt investigate this any further.
I could somehow verify my guess by specifying a default value on the array:
protected $translatableAttributes = ['test'];
In this case, it really contained this value in the syncTranslatableAttributes()-method.
Hope this helps a bit. to identify the error.
I'm having some troubles configuring october cms backend in order to be used by my client who doesn't understand a line of code, and while I'm translating my site's content, I had what might be a great idea:
I'm having some troubles finding a way to give client the ability to change the content of a page without messing around with html and css, putting in risk the page interface, something like drupal where content is updated via input forms.
Maybe translation could accomplish this and be much more than a translations plugin, am I thinking correctly?
The content directory became too congested due to the n number of extra lang files for each file I make so I figured it's a good idea to group them by putting them all in one folder. I changed the component code as {% component 'introduction' file='introduction/intro.htm' %} and then changed the intro.htm, intro.fr.htm, intro.de.htm to introduction/intro.htm, introduction/intro.fr.htm & introduction/intro.de.htm respectively. When I run the website however only the normal english version of it appears i.e. intro.htm and it throws a stack trace error for other languages. When I remove the introduction/ from the other languages it works but then I'm not able to declutter and organise it better!
Update: Something else was wrong, the plugin works even on sub directory levels once I force updated the backend.
I'm editing my pages locally and then uploading them, but even doing clear cache and scan for new message, I get my strings for a partial repeated on the backend each time I re-upload the file... only happens for partials, possible bug?
I think this is related to this issue #18
Is there a way to add translations for a front-end theme to version control, without having to add them to the database? This would allow for a theme to be translated while developing and having the translations available at the moment that the site is put live.
LocalPicker doesn't change the URL path
It would be nice to be able to translate the path when creating a new page.
Taken from #112:
Basically, if I have three languages, for instance "en", "fr", "de", and an about page,
I currently can access :
/en/about
/fr/about
/de/about
For SEO purposes, I would prefer to access (as the same route) :
/en/about
/fr/a-propos
/de/uber-uns
We are developing a custom plugin and we have problems on relation tables.
We have Countries table and offices table. Countries has many offices related to country_id on offices table. We have defined all relations in models and in yaml files.
Every thing works fine on CRUD.
We are implemented translation plugin in to our pluing, Countires tables works great with translation table, but offices table saves blank fields for second language.
When I check the "rainlab_translate_attributes" table I can see recods for "Countries" model but there is no record for Offices Model.
The same thing occurs on "Menu Lists Plugin" here is the thread : https://octobercms.com/forum/post/menu-items-translation-doesnt-work-2
Hi,
don't know if this is the correct name. I am using the translate plugin for me booking plugin, but I already have a lot of rows, so I figure that if I had some other plugins and some text to translate into the front side, there will be a lot of rows, and it would be very difficult to find witch row affect what.
So it would be really great to have something like:
{{ 'My text to translate'|tiipiik.booking|_ }}
Or maybe just have the ability to translate components with the lang files (lang/enlang.php)
To address #42 and #57, I think it could be a good idea to allow the admin to decide whether or not the current locale should be stored in the session.
It could be file-based, with a key like sessionStored
.
Either it's only code editable (config.php file), or it belong to some configuration page.
I would prefer a configuration page, which would also gather other parameters:
It would be nice if it could also support subdomains for languages.
For example:
it.octobercms.com
en.octobercms.com
de.octobercms.com
with the same logic for fallback
octobercms.com ( language = en )
While translating custom models, each time you edit a model, the language for the translatable columns is set to the default language. Couldn't it be set to the current locale instead of the default locale?
Say for example the default is English and you are working on translating custom model to Spanish... it is annoying to set the little language selector inside the translatable column input each time you edit a model.
Is there a workaround for this?
Thanx
Hi,
I have an error with the localePicker. When I choose a language, I get the following error;
AJAX handler 'onSwitchLocale' was not found.
According to this thread, is a October related issue. But I just want to be sure, how can I resolve it?
Please note that mysite.com/{langcode}/
works.
Thanks
Short translation functions are currently restricted to Twig only, PHP needs an equivalent global function to assist with translations.
This may require the addition of a global init.php
script for plugins.
current build 205
in backend i have: http://grab.by/F4dE
in template i use:
When click to make a new language, prompt this error message
Class Rainlab\Translate\Controllers\Locales does not have a method definition for asExtension
It would be cool if the fallback could be set up as:
Just keep the domain but use one specific language (eg. octobercms.com use EN as default)
Redirect to one specific domain which is the default language (eg. octobercms.com -> en.octobercms.com )
On a clean dev-master
October install, with just the translate plugin, when I try to select language with URL prefix an exception is thrown:
Call to undefined method Cms\Classes\Controller::getAfterFilters()
{project-root}/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php line 201
The locale-picker
widget is however working properly.
Hi,
I'm trying to set up the translate plugin, but I can't get it to work.
My site is initially in french (fr) and I want to have en english translation (en).
I think I set up everything fine, but when I call the URL localhost/en/, I have the following exception:
Call to undefined method Cms\Classes\Controller::getAfterFilters()
/.../october/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php line 202
I did a dump
of $instance
and it is of the class Cms\Classes\Controller
(with does not have any getAfterFilters()
)
The normal request (without language prefix), uses a Cms\Classes\CmsController
.
PS: I'm using the latest build (247) of octoberCMS and version 1.0.9 of the translate plugin (I also tried to disable all the other plugins, but it didn't solve my problem)
Hey,
using this plugin for a while now and decided to update it today, because why not, it's awesome.
Added a few more messages to be translated. They appear in the "Settings->Translate Messages" tab after scanning. Entered the translation, cleared the cache, but nothing happens. It's just using the default message, no matter what language I'm choosing (via localePicker or direct URL). Also tried to edit existing messages and they won't update as well. So I'm wondering where else they are actually cached?
Also cleared the browser cache several times just to be sure. It's weird because the setup worked in the past and all I did was updating the plugin and October. Content files are working fine for each of the languages. I'm running with October 238 right now.
Any Ideas on this?
Best,
Christian
Add import and export strings feature to the Messages page.
Hey ,
I am confronting a bug when tried to clear cache : this is the error message :
"Class 'System\Helpers\Cache' not found"
Regards
Create filters that generate links equivalent to the existing ones but with locale prefixes.
For example, when browsing, the urls should go from /es/about-us
to /es/contact-us
instead of just /contact-us
.
These filters may be named _app
, _page
and _themes
.
Is it possible to translate page.htm files? Like page.fr.htm or put pages in subdirectory like /fr/page.htm?
I've tried to put translated pages in subdirectory but current route rules
Route::group(['prefix' => $locale], function() use ($locale) {
Route::any('{slug}', 'Cms\Classes\Controller@run')->where('slug', '(.*)?');
});
Route::any($locale, 'Cms\Classes\Controller@run');
prevents this way of routing. I get 404 on all site.com/fr/page requests.
I update to the last build of OctoberCMS, and I start to test your plugin. But I don't know how to save/validate data using your amazing plugin.
I know is in development status, maybe is not working yet and maybe I'm very excited ...
Thanks.
Add the ability to search messages via the Grid on Messages page.
The translate plugin works beautifully for editing phrases used within the "CMS" code of the web pages, and for data entered using models.
But I need to keep my "client-users" away from editing code in the CMS, obviously. And using the plugin as documented will result in all my default-language phrases being part of the "off limits" code in my CMS pages.
I have thought of a few solutions but I'm not sure what is best.
1: My CMS pages reference content blocks, and I make my client edit text files / content blocks, because I can create them all and add -langcode to the file names. So they can edit page-title.en.txt and page-title.fr.txt without having to modify {{ 'Page Title'|_ }}.
2: I create a "Placeholder" language, so that both English and French become translations. This would be the best client-user experience, but I'm anticipating a few problems on the front end with a default language that I don't really want anyone to ever see.
3: I create a model for each page, with attributes for each placeholder. This seems like it might work nicely, but it a lot of overhead for development and not very flexible as a CMS.
Any advice?
The root page is not found when accessing it with the locale appended in the url.
http://www.example.com/ - Works
http://www.example.com/en - 404
Hello,
We are using Menu List Plugin https://octobercms.com/plugin/flynsarmy-menu
There is two models in the plugin Menu and Menuitems. All models implements the Rainlab Translation plugin correctly. Menu model works great but Menuitem model doesn't save the fields in to rainlab_translate_attributes
I have created a thread here : https://octobercms.com/plugin/flynsarmy-menu/menu-items-translation-doesnt-work-2?page=1#post-6567
With version 1.0.10, although the exception is no longer thrown as reported in #61, #62, and #64, the appropriate language is not being selected with URL prefix.
It seems to me as if no languages is being selected, not even the default language. It shows a 404 page, and when the locale picker is selected on this page an alert message pops up and display the value of X_OCTOBER_REDIRECT
.
Update
The problem only occurs on the root route /
First of all, i must say that u made a great work with this plugin!
It's all done like it should be but i'm missing settings for plural forms (i saw for English, but English have just 2). This is what i miss in all major CMS systems, this could be one of advantages of October.
I am from Slovenia and our language is very complicated, we have 4 plural forms as you can see it on this link under Slovenian (SL) http://localization-guide.readthedocs.org/en/latest/l10n/pluralforms.html.
Is there any way to implement this in this great plugin?
I already made such a plugin, but in javascript for node.js.
Implementation is very simple. This way you can cover all languages around the world. Language file need settings for:
plural form function that calculates plural form index, n is number that user provide. In our language is:
plural_form_index = (n%100==1 ? 1 : n%100==2 ? 2 : n%100==3 || n%100==4 ? 3 : 0);
number of plural forms of Language
numer_of_plural_forms = 4; <- this value you need just in case when u click 'Scan for translations' trough templates, that keys are automatically generated (e.g. 'posts', 'posts.1', 'posts.2', 'posts.3').
So translation for "posts" can be saved like:
Plural form | Translation key or text | Translation of key in Slovenian language |
---|---|---|
form 0 | 'posts' | ':count prispevkov' (when plural_form_index is 0) |
form 1 | 'posts.1' | ':count prispevek' (when plural_form_index is 1) |
form 2 | 'posts.2' | ':count prispevka' (when plural_form_index is 2) |
form 3 | 'posts.3' | ':count prispevki' (when plural_form_index is 3) |
So when translation happen, you just look for same key + dot + plural_form_index on the end, if it doesn't exist, it returns default form 0.
{{ 'posts'|__(2) }}
This means you put 2 in plural form function which outputs plural_form_index = 2, so you look for key 'posts.2' and translate it, if it doesn't exists you try to translate default key 'posts' (default plural form 0).
You can still preserve syntax like this
{{ 'posts|posts.1|posts.2|posts.3'|__(2) }}
, but in this case you will need to know in advance which languages you will use, and how many plural forms they need. So this sounds a little complicated to me.
If you have any questions, do not hesitate.
Thanks for great work!
vizo
right now we have text field and textarea for model translation, but for content we don`t have editor which has ability to translate content.
if we has editor that has translate ability then it is very useful, it can be use for blog and static pages too.
Hi,
A compatibility with the pages-plugins need a support of content from this plugin. I will work on it.
If you want, you can add a Open Bounty.
Thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.