Git Product home page Git Product logo

translate-plugin's People

Contributors

acasar avatar alekseybobkov avatar alxy avatar aurelien-roy avatar bennothommo avatar bmcouto avatar cggstudio avatar daftspunk avatar datune avatar felixinx avatar gergo85 avatar justin-lau avatar luketowers avatar mahony0 avatar mariavilaro avatar mjauvin avatar modmac avatar mplodowski avatar multiwebinc avatar munxar avatar niclasleonbock avatar nnmer avatar octoberapp avatar osmanzeki avatar samgeorges avatar samuell1 avatar tiipiik avatar tobias-kuendig avatar tomaszstrojny avatar vannut avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

translate-plugin's Issues

Add repeater widget support

Currently the new repeater widget form fields cannot be translated. It would be nice to have this feature.

Translate page's title

It's very important to translate page title, makes no sense to change the language and keep page title in another language.

Prefixing the language code to the URL doesn't work

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.

Translating component's template

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); }

Fallback not translated Model properties to default locale

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.

Default root (/) language

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?

  • people often don't look at url, they just make bookmark, share, etc., so if you change default language later, content could be gone on same url, which is very bad.
  • for search engines content is duplicated on two urls: / and /language, which is also bad

Is it possible to make this as an option, that you are always redirected?

So when user come to root, it checks:

  1. if user have language in session, redirect to user's language
  2. if browser sends language in request header, redirect to browser's language
  3. redirect to default language

Thanks in advance,
vizo

Incorrect locale while going from /locale/link to /link

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());

Translating State Model in User plugin.

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.

incorrect filname

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

Plugin installed, without class?

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

[Bug]With Model Translation records for all languages is not stored at time of creation

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.

[Bug] Fix grid scroll disabling other plugin events

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.

Translations when creating Models

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.

This plugin could be the next big thing of OctoberCMS!!

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:

  • What if we could define translations by groups / pages? The plugin would have to identify which page that content belongs to, and then the client could just access translations to change it's content...

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?

Sub-directory language files don't detect

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.

Clear cache not working properly

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?

Cannot translate relation fields

  • Bug summary: When using the plugin on a relation form, translations are not saved to the database
  • Reproduce steps:
    1 Create a relation between two models that are translatable
    2 Create a config_relation on a controller
    3 Render the relation view
    4 Create a new relation record or update an existing one on the form, set the value in the different languages
  • Expected result: The translations are saved on the database
  • Actual result: No translations are saved

I think this is related to this issue #18

Add theme translations to version control

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.

[BOUNTY] Translating page's url & implement translatable indexes

A bounty has been placed on this issue

Scope definition

  • CMS Page URLs should be translatable (see below for technical description)
  • Static Page URLs should be translatable (see #156)
  • Models should support index definitions and lookup mechanism

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

Plugin doesn't work compatible with relation tables

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

[Feature] Adding plugin name to twig

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)

Let admins decide to store the language (locale) in the session

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:

  • Store the lang in the cookies
  • Prevent content duplication:
    • Always redirect to URL with lang suffix
    • Always redirect to URL with lang subdomain prefix
    • ...
    • Nothing
  • Access the default lang via the canonical URL (without suffix/prefix)

[Feature] Subdomain support

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 )

Add the ability to set the current language being translated in the backend

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

AJAX error

Hi,

I have an error with the localePicker. When I choose a language, I get the following error;
AJAX handler 'onSwitchLocale' was not found.
ajax error

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

Add PHP translation helpers

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.

[ Feature ] Fallback configurability

It would be cool if the fallback could be set up as:

  1. Just keep the domain but use one specific language (eg. octobercms.com use EN as default)

  2. Redirect to one specific domain which is the default language (eg. octobercms.com -> en.octobercms.com )

Selecting language with URL prefix throws exception

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.

Exception when calling an URL in an other language

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)

Messages won't translate

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

Untranslated strings found

  1. After installing this plugin, please click Settings in the back-end.
  2. The caption of 'Translation', 'Languages', 'Messages' and their descriptions remain English.

Cash clear crash

Hey ,
I am confronting a bug when tried to clear cache : this is the error message :
"Class 'System\Helpers\Cache' not found"

Regards

Page translation

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.

[question] This plugin is usable right now?

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.

Best Practice for Translating editable content

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?

Selecting language with URL prefix doesn't work on root route

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 /

Plural forms

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.

For example:

{{ '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

[feature] With model translation can we have editor ?

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.