localized date_selector

localized date_selector

by Tobias Uhmann -
Number of replies: 5

Hi everybody,

is there a way to get non-English month names in Moodle's date_selector? (https://docs.moodle.org/dev/lib/formslib.php_Form_Definition#date_selector)

Posted a more detailed question on Stackoverflow: https://stackoverflow.com/questions/56294721/moodle-localized-date-selector

Average of ratings: -
In reply to Tobias Uhmann

Re: localized date_selector

by Renaat Debleu -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

The date selector is automatically showing localized months based on the course or user language:

french

Average of ratings: Useful (1)
In reply to Tobias Uhmann

Re: localized date_selector

by David Mudrák -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators
In reply to David Mudrák

Re: Re: localized date_selector

by Tobias Uhmann -
That was it. We're using Bitnami's docker image for Moodle in our development environment. Installing a language pack after starting the containers yields the following message:



Apparently, the Docker image lacks the necessary i18n tools or configuration. We've experienced similar problems when trying to setup the test database in Docker.

We didn't notice the error in the GUI because we import our "fixture database" via command line after startup.
In reply to Tobias Uhmann

Re: Re: Re: localized date_selector

by Darko Miletić -
Most of the docker images use base debian 9 image which only contains english locale. To add other locale definitions do the following after starting the container image:

apt-get -q update
apt-get -yq install locales
sed -i 's/# de_DE.UTF-8 UTF-8/de_DE.UTF-8 UTF-8/g' /etc/locale.gen
sed -i 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/g' /etc/locale.gen
locale-gen
update-locale 'export LC_ALL="de_DE.UTF-8"'
. /etc/default/locale

This enables and installs English usa and German locale and defines German as default



Average of ratings: Useful (2)
In reply to Tobias Uhmann

Re: localized date_selector

by Dominique Palumbo -
Picture of Particularly helpful Moodlers Picture of Plugin developers

hi,

in fact as Renaat wrote it, in code, I just create the date selector using doc, like that.

$mform->addElement('date_time_selector', 'open', get_string('opendate', 'mod_xyz'),array('startyear' => 2018,'stopyear'  => 2050,'timezone'=> 99,'step'=> 5));

And it's automaticaly localized.


But it's  only work with languages that are installed.  (if the language is not installed it's english by default)

Maybe in your development environment you only install english by default and not other languages ?


Hope it's help.