Git Product home page Git Product logo

silverstripe-fluent's Introduction

Fluent

Build Status Scrutinizer Code Quality codecov SilverStripe supported module

Simple Silverstripe Localisation

This module allows websites to manage localisation of content, and navigation between localisations, in a similar fashion to Translatable or Multilingual.

Locales are distinguished by a url prefix, that of the selected locale, at the start of all page links. E.g. http://damian.geek.nz/en_NZ/about-me would be the NZ English version of a page. This could be localised into Maori at http://damian.geek.nz/mi_NZ/about-me

Fluent also integrates nicely with Google Sitemaps module, linking localisations for each page as per Google's internationalisation guidelines

Fluent also supports the use of multiple domains to assist in locale filtering (e.g. a .com for English, and a .cn for Chinese).

Back end control is provided by a simple CMS filter.

Locale Menu

Also, please report any issues you may encounter, as it helps us all out!

Contributing

If you would like to contribute to Fluent, either via pull requests, localisations, or being a part of the contributing team, please see the contributing guidelines

Credits and Authors

Requirements

  • SilverStripe 4.0.0 or above
  • PHP 7.1 or above

Documentation

Translations

The translations for this project are managed via Transifex and are updated automatically during the release process. To contribute, please head to the link above and get translating!

License

Revised BSD License

Copyright (c) 2018, Damian Mooyman

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • The name of Damian Mooyman may not be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

silverstripe-fluent's People

Contributors

aljosab avatar blasic avatar bumbus avatar chillu avatar davejtoews avatar dependabot[bot] avatar dhensby avatar elvinas-liut avatar emteknetnz avatar guysartorelli avatar guyvanbael avatar h7io avatar jorisdebonnet avatar lekoala avatar maxime-rainville avatar mfendeksilverstripe avatar mikey-harveycameron avatar nightjar avatar oetiker avatar oliver-norden avatar phptek avatar raissanorth avatar robbieaverill avatar scopeynz avatar stevie-mayhew avatar taoceanz avatar tony13tv avatar tractorcow avatar undefinedoffset avatar wernerkrauss 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

Watchers

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

silverstripe-fluent's Issues

Problem with is_frontend() function ( Very serious )

Hi Damian!

I was having problems with the CMS to write a record with the correct values ​​from Fluent.

When researching I discovered that is_frontend() function returns a bad result in some cases, for example with the following URL:
/admin/pages/edit/EditForm/field/URLSegment/suggest/?value=JfControls%20Standard

    public static function is_frontend() {

        // No controller - Possibly pre-route phase, so check URL
        if(!Controller::has_curr()) {
            $base = preg_quote(Director::baseURL(), '/');
            return !preg_match('/^'.$base.'admin(\/|$)/i', $_SERVER['REQUEST_URI']);
        }

        // Detect all admin controllers
        $controller = Controller::curr();
        return !($controller instanceof AdminRootController)
            && !($controller instanceof LeftAndMain);
    }

If $_SERVER['REQUEST_URI'] contain the URL

admin/pages/edit/EditForm/field/URLSegment/suggest/?value=JfControls%20Standard

then

return !preg_match('/^'.$base.'admin(\/|$)/i', $_SERVER['REQUEST_URI']);

return true
so get_persist_locale() function returns a bad result, because $key variable has the value 'FluentLocale' instead of 'FluentLocale_CMS'.

Thanks,
Regards,
Jose A.

has_many or many_many relations

In the documentation you indicate that "If you wish to translate has_many or many_many then those objects will need to be filtered via another method. See Locale based filter configuration".

In the section "Locale based filter configuration" is not clear how to do this type of relationship.

You could put some concrete example.

For example, if we have:

class SendaElement extends DataObject {
    private static $many_many = array(
        'Elements' => 'SendaElement'
    );
}

Somehow, with the Fluent module installed should be as something like:

class SendaElement extends DataObject {
    private static $many_many = array(
        'Elements' => 'SendaElement'
    );
    private static $translate = array(
        'Elements'
    );
}

and if locales are en_US and es_ES it should be create two tables:

SendaElement_Elements_en_US
SendaElement_Elements_es_ES

According to the active locale will automatically use a table to another.

Can it be?

Thanks,
Regards,
Jose A.

Comments module and Forum module problem

Hi Damian!

When the Comments module is installed (https://github.com/silverstripe/silverstripe-comments), new added comments should be displayed only when the language in which they were introduced is active.

That is, when the Spanish language is active and displays a blog article, the new comments that are added ​​at that time should be displayed only when the active language is Spanish.

For this, the Comment table should include a Locale field to filter by that field.

The same goes for the Forum module (https://github.com/silverstripe/silverstripe-forum), new posts added in a forum section should be displayed only when the language in which they were introduced is active on the web.

For this, the ForumThread table should include a Locale field to filter by that field.

Surely, Fluent module should have an extension in order to control this type of case.

Thanks Damian,
Regards,
Jose A.

loop Menu(1) and FluentFilteredExtension

Hi Damian,

In templates to display the menus we do the following:
<% loop Menu(1) %>
<% loop Children %>
.....
This mechanism does not respect the pages to which has been applied FluentFilteredExtension extension.

The menu shows all pages.

Regards,
Jose A.

Locale selector bit dodgy

The selector in the CMS seems to be a bit dodgy, sometimes it shows up and sometimes it doesnt show up.

I find it hard to reproduce this. So cant make a really better description, it just happens while browsing through the sitetree.

set_date_format and set_time_format deprecated

Hi!

    /**
     * Installs the current locale into i18n
     */
    public static function install_locale() {

        // Ensure the locale is set correctly given the designated parameters
        $locale = self::current_locale();
        i18n::set_locale($locale);
        setlocale(LC_ALL, $locale);

        // Get date/time formats from Zend
        require_once 'Zend/Date.php';
        i18n::set_date_format(Zend_Locale_Format::getDateFormat($locale));
        i18n::set_time_format(Zend_Locale_Format::getTimeFormat($locale));
    }

i18n::set_date_format(Zend_Locale_Format::getDateFormat($locale));
i18n::set_time_format(Zend_Locale_Format::getTimeFormat($locale));

This functions are deprecated.

Regards,
Jose A.

Problem with is_frontend() function ( Still problems )

Hi Damian!

There are still problems with detection.

The following module is not working:
https://github.com/sunnysideup/silverstripe-ecommerce_product_variation

This module uses a CMS controller (CreateEcommerceVariations) that inherits from the Controller class, so that is not detected:

public static function is_frontend($ignoreController = false) {

        // No controller - Possibly pre-route phase, so check URL
        if($ignoreController || !Controller::has_curr()) {
            // $_SERVER['REQUEST_URI'] indeterminatelys lead with '/', so trim here
            $base = preg_quote(ltrim(Director::baseURL(), '/'), '/');
            return !preg_match('/^(\/)?'.$base.'admin(\/|$)/i', $_SERVER['REQUEST_URI']);
        }

        // Detect all admin controllers
        $controller = Controller::curr();
        return !($controller instanceof AdminRootController)
            && !($controller instanceof LeftAndMain);
    }

The following line return true:

        return !($controller instanceof AdminRootController)
            && !($controller instanceof LeftAndMain);

I tried to inherit from LeftAndMain or AdminRootController, but the module does not work this way.

However, sometimes the following line is met:

if($ignoreController || !Controller::has_curr()) {

so run the following lines:

            $base = preg_quote(ltrim(Director::baseURL(), '/'), '/');
            return !preg_match('/^(\/)?'.$base.'admin(\/|$)/i', $_SERVER['REQUEST_URI']);

The URL is:

$_SERVER['REQUEST_URI']= /createecommercevariations/rename/17/?typeorvalue=value&value=full%2520licensecaca33&id=2

so, this code return true:

            $base = preg_quote(ltrim(Director::baseURL(), '/'), '/');
            return !preg_match('/^(\/)?'.$base.'admin(\/|$)/i', $_SERVER['REQUEST_URI']);

it is also wrong. :(

What do you think?
Which do you believe will be the best solution?

Thanks,
Regards,
Jose A.

Now fluent does not save the last user's language selection.

Something has changed in the latest versions of fluent.
Now fluent does not save the last user's language selection.
That is,

  • Initially I go to 127.0.0.1. Then is shown the page of default language: english
    In the edit bar browser shows 127.0.0.1
  • Now select the Spanish language with page selector http://127.0.0.1/es-es/
    Selected correctly and in the edit bar browser is shows http://127.0.0.1/es-es/
  • Now close the browser.
  • I reopen the browser and put 127.0.0.1 .
    The browser opens the page in English, unaware that the last page was in Spanish.
    Should've gone automatically to http://127.0.0.1/es-es/

Temp Locale

Hi Damian!

Sometimes you have to perform operations on a dataobject with a temporary locale without changing the current locale.
It might be interesting to have a set of functions that would connect a locale temporarily for specific operations.

The functions could be:

Flush.php
public static function SetTempLocale($locale) {
  self::$tempLocale = $locale;
}
public static function GetTempLocale($locale) {
  return self::$tempLocale;
}
public static function ClearTempLocale() {
  self::$tempLocale = null;
}

Now would you modify the current_locale() code to take account of this temporary variable.
In this way it is not necessary to touch the session variables or cookies ('FluentLocale).

What do you think?

Thanks,
Regards,
Jose A.

Problem with Lost password notification

Hi Damian!

The notifications do not take into account the locale.

Look at the following images:
loginpassword_sc1
loginpassword_sc2
loginpassword_sc3

The english notification is in MemberLoginForm.php

public function forgotPassword($data) {
.....
$this->sessionMessage(
                _t('Member.ENTEREMAIL', 'Please enter an email address to get a password reset link.'),
                'bad'
            );
.....

This is because install_locale method not running when the notification occurs.

Regards,
Jose A.

Login URL (Security/login) and website Locale selector

When I'm on the login page the website local selector not working .

<% include LocaleMenu %>

If I include in the selector link the locale ?FluentLocale= :

 <li class="en_US"><a href="Security/login?FluentLocale=en_US" hreflang="en_US" title="English (United States)"><img class="imageflags" src="senda/images/flags/en_US.gif"> English (United States)</a></li>

 <li class="es_ES"><a href="Security/login?FluentLocale=es_ES" hreflang="es_ES" title="Spanish (Spain)"><img class="imageflags" src="senda/images/flags/es_ES.gif"><strong> Spanish (Spain)</strong></a></li>

This does not work because Controller::has_curr() return false in current_locale function (Fluent.php).
You may have to use $_REQUEST to get the value of FluentLocale in current_locale function.

If you can solve this problem I think that Fluent will have no bugs and the module is ready for the most demanding sites. :)

Thanks Damian,
Regards,
Jose A.

saving wrong value, when entering same value for Title and MenuTitle

I set up fluent to work with two locales (default de_DE, en_US).

  1. I create a new Page for de_DE and enter content for that language.
  2. I switch to en_US and also enter content for that language. Whenever I enter the same values for "Title" and "Menu Title" and save/publish the page, the "Menu Title" does not have have the before entered value. It has the value that was set for the default locale, which is de_DE in my case.

I think the problem is, that silverstripe would set NULL for the Menu Title field, whenever the Title and Menu Title inputs are the same. Fluent recognises that it would be NULL and automatically sets the value that is already defined in the standard "Title" field.

For example:

  1. I set MenuTitle = "foo" and MenuTitle_de_DE = "foo"
  2. now I try to set Title_en_US AND MenuTitle_en_US to "bar"
  3. after saving Title_en_US = "bar", but MenuTitle_en_US = "foo"

If in step 2 I enter Title_en_US = "bar" and MenuTitle_en_US = "bar2" everything works fine.

I hope you understand my problem?!

Domain filters for locales

Following on from the discussion at #42 fluent needs to be updated to cater for domain switches for locales.

I think the most important thing is that it's easy to configure and use. I propose a config schema similar to the below:

---
Name: myfluentconfig
After: '#fluentconfig'

---
Fluent:
  domains:
    us.domain.com:
      locales:
        - 'en_US'
        - 'es_US'
      default_locale: 'en_US'
    oceania.domain.com:
      locales:
        - 'en_NZ'
        - 'en_AU'
      default_locale: 'en_NZ'
    ca.domain.com:
      locales:
        - 'en_CA'
    www.domain.fr:
      locales:
        - 'fr_FR'

I considered allowing the baseURL prefix (E.g. /en_NZ/) to be omitted for domains with only a single locale, but I think a better solution (and referring to #42 above) is to not require the prefix for the home page for the default locale on any domain. This has the added benefit of removing a redirect when landing on the domain home page.

The home pages for each locale would be:

  • us.domain.com
  • us.domain.com/es_US
  • oceania.domain.com
  • oceania.domain.com/en_AU
  • www.domain.fr

Considering that it can be difficult to work with live configurations in the main yaml configuration file (especially when testing locally) I imagine that the routing scheme would only be active when the current domain was one of the customised domains (so running off localhost would not trigger the switch).

Any comments on this?

Translatable > Fluent migration tool?

Does anyone need a migration tool for translatable websites? I was thinking I could develop a migration task for users who want to migrate a site, or test out how their existing translatable site performs using fluent.

Browser Locale

Hi Damian!

I have a function that returns the browser language from priorities, but I do not know if it's better that you have included in the code.
It takes into account the member locale.
I'll put it below should you want to see.

   $locale = Cookie::get('senda_lang');
                    if (!isset($locale)) {
                        $uid = Cookie::get('senda_mem');
                        if (isset($uid) && ($uid != 0)) {
                            $member = Member::get_by_id("Member", $uid);
                            if ($member) {
                                $locale = $member->locale;
                            }
                        }
                        if (!isset($locale) || !(in_array($locale, $langsAvailable))) {
                            $locale = self::default_locale();
                            // First try to detect browser preferred language
                            if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
                                $locales = array();
                                $list = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
                                foreach($list as $part) {
                                    $priority = '';
                                    @list($_locale, $priority) = explode(';', $part);
                                    if ($priority) {
                                        $priority = substr($priority, 2);
                                    } else {
                                        $priority = 1.0;
                                    }
                                    if (preg_match('/^([a-zA-Z]+)$/', $_locale, $match)) {
                                        if (isset(i18n::$likely_subtags[$match[1]])) {
                                            $_locale = i18n::$likely_subtags[$match[1]];
                                        } else {
                                            $_locale = self::default_locale();
                                        }
                                    } else if (preg_match('/^([a-zA-Z]+)-([a-zA-Z]+)$/', $_locale, $match)) {
                                        $_locale = $match[1] . '_' . strtoupper($match[2]);
                                    } else {
                                        $_locale = self::default_locale();
                                    }
                                    if (in_array($_locale, $locales) == false) {
                                        $locales[$priority] = $_locale;
                                    }
                                }
                                // Sort browser locales by priority
                                krsort($locales);
                                // Try to find best matching browser locale
                                foreach($locales as $_locale) {
                                    if ($langsAvailable) {
                                       if (isset($langsAvailable) && in_array($_locale, $langsAvailable)) {
                                            $locale = $_locale;
                                            break;
                                        }
                                    } else if (self::$allowed_locales) {
                                        if (in_array($_locale, self::$allowed_locales)) {
                                            $locale = $_locale;
                                            break;
                                        }
                                    } else {
                                        if (isset(i18n::$all_locales[$_locale])) {
                                            $locale = $_locale;
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    }
           //  }
            }

Regards,
Jose A.

Publishing page issue

If publishing a page outside of the default locale, the default locale field will not be published.

To reproduces:

  • Change to a non-default locale in the CMS
  • Create and publish a page
  • View this page on the frontend in the default locale. The title will be blank, but a record will exist.

Translated fields get filled in

I have a setup of two locales in ModelAdmin and I translate two fields, Description & Stad.

I create a new dataobject in Locale Dutch and I fill in Description and Stad as I want. When I then switch to Locale English both Description and Stad have the same value as the Locale Dutch.

I think those fields shouldnt be "listening" and should be kept empty, this can confuse the end-user. Also when leaving the fields empty it shows that those fields are being translated.

Example:
I fill in the fields and save.
schermafbeelding 2013-07-25 om 14 37 16

Then I switch to the Dutch Locale [Ideally, the Description field here should be empty]
schermafbeelding 2013-07-25 om 14 37 27

Frontend LocaleMenu LinkingMode

I have tried to fix this myself, but unfortunately didn't get it a proper pull request so I am forced to request this feature.

Would it be possible on the frontend LocaleMenu to have a active language. This could hide the language that is selected, change the opacity or in whatever way you want it styled.

Login URL (Security/login)

If my fluent.yaml is:


---
Name: myfluentconfig
After: '#fluentconfig'

---
Fluent:
  default_locale: en_US
  locales:
    - en_US
    - es_ES
  aliases:
    en_US: en-us
    es_ES: es-es

---
Name: myfluenti18nconfig
After: '#fluenti18nconfig'

---
i18n:
  default_locale: en_US

I think this URL would be to work:
http://127.0.0.1/es-es/Security/login

but:

Sorry, it seems you were trying to access a page that doesn't exist.
Please check the spelling of the URL you were trying to access and try again.

Thank you for this wonderful module.

Regards,
Jose A.

SiteTreeURLSegmentField doesn't respect locale for top level pages

Need to investigate replacement for SiteTreeURLSegmentField with an alternative that generates correct URLs.

When viewing a top level page the URL doesn't appear to contain the locale, but second level pages do. The field needs to be updated to consider that the locale needs to be injected between the BaseURL and the root page URLSegment.

Should be pretty easy to fix.

Disable FluentMySQLSearch class

Hi Damian!

I tried the following, but does not work (mysite/_config/fluent.yaml):

Fluent:
  search_adapters:
    MySQLDatabase: null

The FluentMySQLSearch class methods still running (augmentSearch, getSearchFilter, ...)

.If I replace the following in fluent/_config/fluent.yml:

  search_adapters:
    MySQLDatabase: FluentMySQLSearch

by

  search_adapters:
    MySQLDatabase: null

the following error occurs when doing dev/build:

Fatal error: Class name must be a valid object or a string in C:\wamp\www\fluent\code\Fluent.php on line 386

    public static function search_adapter() {
        foreach(self::config()->search_adapters as $connector => $adapter) {
            if(DB::getConn() instanceof $connector) {
                return new $adapter();
            }
        }
    }

This is because $adapter is null.

You ask me "What kind of search are you using?"
I'll explain in more detail here: https://github.com/tractorcow/silverstripe-fluent/issues/19

Thanks,
Regards,
Jose A.

LocalisedFields, SiteTree and updateCMSFields problem

Hi Damian!

I have observed that an extension to sitetree not display the icon on the fields that can be translated.

class SiteTreeDecorator extends DataExtension {
  function updateCMSFields(FieldList $fields) {
      $fields->insertBefore(
                $contentstructure = TextareaField::create('ContentStructure', 'Content Structure'), 'Content'
      );
  }
}

Can I solve this problem somehow?

Thanks Damian,
Regards,
Jose A.

Flushing gives problems

When adding a include you are usually forced to flush.

Now when I flush like, http://www.mysite.com?flush=all I keep getting the same error that the template cannot be found.

Once I do, http://www.mysite.com/nl?flush=all - the flushing works like it usually works.

When switching language I am not sure if the other language got flushed aswell. It seems abit dodgy, it does show up the error but once I do a normal refresh - the error seems gone.

detect_locale not work

Now the
Fluent:
detect_locale: true
not work

If I put 127.0.0.1 the browser goes to the page with the default languaje (english), not to the page with the browser language (spanish).

Regards,
Jose A.

phpunit: Notice: Undefined index: REQUEST_URI

When I run my unit tests (only the ones located within </mysite>), I get the following error from phpunit:

Notice: Undefined index: REQUEST_URI in .../fluent/code/Fluent.php on line 293

Call Stack:
    0.0026     632440   1. {main}() .../vendor/phpunit/phpunit/composer/bin/phpunit:0
    0.0128    1097776   2. PHPUnit_TextUI_Command::main() .../vendor/phpunit/phpunit/composer/bin/phpunit:63
    0.0128    1098504   3. PHPUnit_TextUI_Command->run() .../vendor/phpunit/phpunit/PHPUnit/TextUI/Command.php:129
    0.0128    1098504   4. PHPUnit_TextUI_Command->handleArguments() .../vendor/phpunit/phpunit/PHPUnit/TextUI/Command.php:138
    0.0193    1764456   5. PHPUnit_TextUI_Command->handleBootstrap() .../vendor/phpunit/phpunit/PHPUnit/TextUI/Command.php:606
    0.0197    1780936   6. PHPUnit_Util_Fileloader::checkAndLoad() .../vendor/phpunit/phpunit/PHPUnit/TextUI/Command.php:778
    0.0202    1781072   7. PHPUnit_Util_Fileloader::load() .../vendor/phpunit/phpunit/PHPUnit/Util/Fileloader.php:76
    0.0206    1815520   8. include_once('.../framework/tests/bootstrap.php') .../vendor/phpunit/phpunit/PHPUnit/Util/Fileloader.php:92
    0.0285    1935984   9. require_once('.../framework/core/Core.php') .../framework/tests/bootstrap.php:46
    8.5159    9089856  10. Config->pushConfigYamlManifest() .../framework/core/Core.php:117
    8.5168    9089928  11. SS_ConfigManifest->activateConfig() .../framework/core/Config.php:309
    8.5281   12900104  12. require_once('.../fluent/_config.php') .../framework/core/manifest/ConfigManifest.php:141
    8.5286   13101344  13. Fluent::init() .../fluent/_config.php:4
    8.5286   13101392  14. Fluent::install_locale() .../fluent/code/Fluent.php:49
    8.5286   13101392  15. Fluent::current_locale() .../fluent/code/Fluent.php:370
    8.5297   13544880  16. Fluent::get_persist_locale() .../fluent/code/Fluent.php:77
    8.5297   13544928  17. Fluent::is_frontend() .../fluent/code/Fluent.php:131

PHPUnit 3.7.27-dev by Sebastian Bergmann.

Configuration read from .../phpunit.xml

.

Time: 2.25 seconds, Memory: 95.25Mb

OK (1 test, 1 assertion)

Amazing module by the way! Many thanks for your effort!

Language selection in CMS and frontend simultaneously (Serious Problem)

Hi Damian!

If I open two tabs in browser.
In the first tab open the CMS and select a record of a class that inherits from DataObject (ModelAdmin) and select the English language.
In the second tab I open the website that I'm creating and select another language with its language selector, for example, Spanish.
Now I select CMS tab and I click on the 'Save' button in the CMS.
In that record that I saved, the English language texts overwrites the Spanish language texts of the multilanguage fields.

In summary, the cookie for the locale that you use in the CMS should be different to that used in the frontend, since side effects may occur.
You will need to include a current_locale() method for CMS and a different one for the FrontEnd.

Regards,
Jose A.

Disable FluentMySQLSearch class

Hi Damian!

How I can disable FluentMySQLSearch class?
If I delete the following lines in the fluent.yml file errors occur.

  search_adapters:
    MySQLDatabase: FluentMySQLSearch

I use a proprietary search.

Thanks,
Regards,
Jose A.

ModelAdmin Dataobjects

At the moment I think its very messy how the translate fields are being shown.

I have a DataObject with:

private static $db = array(
        "Jaartal" => "Varchar(255)",
        "StartDate" => "Date",
        "EndDate" => "Date",
        "Description" => "HTMLText",
        "Land" => "Varchar(10)",
        "Stad" => "Varchar(255)",

        "ExceliFrame" => "HTMLText",

        // Prijzengeld
        "PrijsPlaatsEen" => "Varchar(255)",
        "PrijsPlaatsTwee" => "Varchar(255)",
        "PrijsPlaatsDrie" => "Varchar(255)",
        "TotaalPrijzengeld" => "Varchar(255)",

        // Kampioen
        "KampioenNaam" => "Varchar(255)",
        "KampioenLand" => "Varchar(10)"
    );

All fields are currently being translated because of the following setting in fluent.yml:

    - 'Text'
    - 'Varchar'
    - 'HTMLText'
    - 'HTMLVarchar'

While I would for example only want Description, Land to be translated in this DataObject.

But then I come to the messy part, all the fields are being thrown in the main tab including en_US and nl_NL and they also seem to duplicate once.

So I have Voornaam, Voornaam_nl_NL and Voornaam_en_US get added. But I think it should only shown Voornaam_nl_NL and Voornaam_en_US.

silverstripe toernooien

silverstripe toernooien

I hope I made myself clear enough otherwise you know where to find me!

Locale Filter for pages

Hi there,

Great module, having much more success with it than the other translation modules!

Question, is it possible to use the locale filter for pages? So I can select a page to not show in a certain language?

Cheers

Translation for Enum

There are some i18nEnum outthere, but those only allow support for the CMS and not on the frontend.

Would this feature be possible? It seems like a big request though :(

If not, what could I use as alternative solution? I have been struggling with this for awhile.

license

the composer.json file states that the license is BSD, however in the readme is no mention of it under the license point

please ensure the license information is consistent

URL resolution and FluentFilteredExtension (NEW)

You probably should not create separate forums for different languages, if you expect them to act as a single translated page. I'd suppose the better way to do this is to create one forum, and to apply a locale filter to the individual posts onBeforeWrite (as discussed earlier), but I'll leave this choice up to you. :) The downside of the way that you've chosen above is that now links between locales don't correspond to these two pages, as it's only meant to work on a single SiteTree object. Go back to using a single translated forum page and it'll work as expected. See my comment at #24 for help.

That was my first try, because this is the best solution, unfortunately the forum does not work properly with this technique.
In my first attempt FluentFilteredExtension applied to ForumThread class and put the onBeforeWrite event in an extension for that class.
In this way the forum works properly, but the counters of topics and posts do not respect the locale.

See picture below.

forum

I will see if I can change those counters.

Sorry if I've written too much lately.
I will try to disturb as little as possible. ;)
Do you prefer to write you directly to your email?

Thanks Damian,
Regards,
Jose A.

Googlesitemaps custom dataobjects

Since the update for Googlesitemaps the custom dataobjects no longer are shown up, while they worked before. So it seems related to Fluent.

Need a nicer locale dropdown

The locale dropdown in the CMS isn't very attractive, but I'm not really much of a designer. Can someone come up with a design concept for a better, more attractive menu? Maybe something that distinguishes itself a little more from the rest of the menu?

[REQUEST] Autolanguage mode (browser language)

Hi!

It would be interesting that the first time a user accesses a website will be displayed in the language of your web browser and if that language is not defined then in the default language.
If the user selects another language, this selection would be stored in a cookie for the next time the user visits the web.

Thanks,
Regards,
Jose A.

Feature: Locale aliases

It would be nice to have aliases for each locale for urls, so that we could have

/en/page instead of /en_NZ/page.

Will need to create an alias mapping option for each so that the values can be customised.

CMS Interface Language

I have a user with Interface Language Dutch, but sometimes when going through the CMS it switches to English and sometimes to Dutch.

Seems like the Locale isn't always being loaded well. This didn't acquire before.

Translatable URLs

On the frontend the URLs of the LocaleMenu doesn't seem to update to the locale URLSegment value.

/en/tournaments <- URLSegment_en_US
/nl/toernooien <- URLSegment

On the frontend only seems to read URLSegment

URL resolution and FluentFilteredExtension

Hi Damian,

To work properly the forums I had to create a forum page in English and one in Spanish.

I have applied FluentFilteredExtension extension to the ForumHolder page, so through the CMS I could indicate what is the English forum and what is the Spanish forum .

The English Forum URLSegment is forums (http://127.0.0.1/en-us/support/forums).
The Spanish forum URLSegment is foros (http://127.0.0.1/es-es/support/foros).

Now I have a problem with the language selector. <% include LocaleMenu %>

If I am in English forum, ie http://127.0.0.1/en-us/support/forums,
and try to move to the spanish forum through the website language selector,
the page that is selected is URL is http://127.0.0.1/es-es/support/forums/
What shows the english forum with texts in spanish.

Should not be able to select this URL http://127.0.0.1/es-es/support/forums/ , because through FluentFilteredExtension I have indicated that the Forums page is only for English, not Spanish.
It should be shown the error page 404.

There should be an automatic mechanism by which we could say that
http://127.0.0.1/en-us/support/forums (for the English page)
is equivalent to
http://127.0.0.1/es-es/support/foro (for the Spanish page)

What do you think?

Thanks,
Regards,
Jose A.

CMS interface language

This is my fluent.yml

Name: myfluentconfig
After: '#fluentconfig'

---
Fluent:
  default_locale: nl_NL
  locales:
    - en_US
    - nl_NL

---
Name: myfluenti18nconfig
After: '#fluenti18nconfig'

---
i18n:
  default_locale: nl_NL

Currently the CMS interface language is always en_US and when I try to change it in the CMS to Dutch, it just switches back to English (US).

Temp Locale (New)

Hi Damian!

In your solution there are some problems, for example, when you are entering a new record:

$rec = new ElementCache();
$rec->field1 = 'datafield1';
$rec->field2 = 'datafield2';
$rec->write();

With your system this could not be done with a different locale.

I think a better solution is:

Flush.php
public static function SetTempLocale($locale) {
  DataObject::flush_and_destroy_cache();
  self::$_override_locale = $locale;
}
public static function ClearTempLocale() {
  DataObject::flush_and_destroy_cache();
  self::$_override_locale = null;
}

public static function current_locale() {

        $locale = null;

       if(self::$_override_locale) return self::$_override_locale;

            // Check controller and current request
            if(Controller::has_curr()) {
                $controller = Controller::curr();
                $request = $controller->getRequest();

                if(self::is_frontend()) {
                    // If viewing the site on the front end, determine the locale from the viewing parameters
                    $locale = $request->param('FluentLocale');
                }

                if(empty($locale)) {
                    // If viewing the site from the CMS, determine the locale using the session or posted parameters
                    $locale = $request->requestVar('FluentLocale');
                }
            }

            // check session
            if(empty($locale)) $locale = Session::get('FluentLocale');

            // Check cookies
            if(empty($locale)) $locale = Cookie::get('FluentLocale');

            // Check result
            if(empty($locale)) $locale = self::default_locale();

            // Reset to default locale if not listed in the specified list
            $allowedLocales = self::locales();
            if(!in_array($locale, $allowedLocales)) $locale = self::default_locale();

            // Save locale
            Session::set('FluentLocale', $locale);

            // Prevent unnecessarily excessive cookie assigment
            if(!headers_sent() && self::$last_set_locale !== $locale) {
                self::$last_set_locale = $locale;
                Cookie::set('FluentLocale', $locale);
            }
        return $locale;
    }

In this way:

Flush::SetTempLocale('es_ES');
$rec = new ElementCache();
$rec->field1 = 'datafield1';
$rec->field2 = 'datafield2';
$rec->write();
Flush::ClearTempLocale();

I 've tried this system and it works perfectly.

What do you think?

Thanks,
Regards,
Jose A.

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.