?
avatar Mausino
Mausino
4 May 2018

Steps to reproduce the issue

I want custom values for calendar pop up system window in own region language

Expected result

Can add it via overrides, because i must create js file in system

media/system/js/fields/calendar-locales/en.js
or
media/system/js/fields/calendar-locales/de.js or

Actual result

My employees can't control language on all site.. need IT to solve some problems with tranlations

Joomla 3.8.7

avatar Mausino Mausino - open - 4 May 2018
avatar joomla-cms-bot joomla-cms-bot - change - 4 May 2018
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 4 May 2018
avatar zero-24
zero-24 - comment - 4 May 2018

What kind of problems do you have with the german or original translations?

Maybe we can fix them upstream so no need to override that yourself.

Iirc there is also a way to override the files in media but I don't know it by heart need to check that later if not somone else beat me with it ;-)

avatar brianteeman
brianteeman - comment - 4 May 2018

I think this is the post you are referring to about overriding /media

https://www.babdev.com/blog/139-use-the-media-folder-allow-overridable-media

avatar Mausino Mausino - change - 4 May 2018
The description was changed
avatar Mausino Mausino - edited - 4 May 2018
avatar Mausino
Mausino - comment - 4 May 2018

@zero-24 i don't have problem with original translations... but we creating the region languages which are many differencies between original language and region/folk language

My question is: why can't be by overrides tranlate all words (text) in whole joomla ?

@brianteeman i didn't know before about this article.. but it helps a lot :) thank you

avatar franz-wohlkoenig franz-wohlkoenig - change - 4 May 2018
Title
Can't translate the calendar language values by overridess
Can't translate the calendar language values by overrides
Status New Discussion
avatar joomla-cms-bot joomla-cms-bot - edited - 4 May 2018
avatar franz-wohlkoenig franz-wohlkoenig - change - 4 May 2018
Category Language & Strings
avatar infograf768
infograf768 - comment - 4 May 2018

My question is: why can't be by overrides tranlate all words (text) in whole joomla ?

question to @dgrammatiko
The simple reply is that these lang values are javascript, (would be a similar reply for TinyMce lang values).

avatar dgrammatiko
dgrammatiko - comment - 4 May 2018

It should be overridable through the template, if it’s not then I wrongly hardcoded it. But using php (cpu cycles) to generate json files is pretty stupid and wrong pattern imho

avatar brianteeman
brianteeman - comment - 4 May 2018

@zero-24 i don't have problem with original translations... but we creating the region languages which are many differencies between original language and region/folk language

You should be doing this as complete language files then and not overrides - and it will make them reusable across more than one site

avatar dgrammatiko
dgrammatiko - comment - 4 May 2018

@infograf768 @Mausino I've just checked the code and all the assets are overridable :

JHtml::_('script', $localesPath, false, true, false, false, true);
JHtml::_('script', $helperPath, false, true, false, false, true);
JHtml::_('script', 'system/fields/calendar.min.js', false, true, false, false, true);
JHtml::_('stylesheet', 'system/fields/calendar' . $cssFileExt, array(), true);

Just a bit of the history why we did it with a static file instead of PHP:

  • we wanted to eliminate the risk of unusable calendar due to missing strings
  • performance, wrote about it in the previous comment as well

So although this doesn't follow the usual workflow for overriding lang strings, it is still possible, all you need to do is copy the files you need to override from media\system\fields\calendar\calendar-locales\[language code].js to your template's js folder and then edit the strings to fit your need

avatar mbabker
mbabker - comment - 4 May 2018

It looks like it's still somewhat dependent on the thing you want to override existing in the media directory first:

// Get the appropriate locale file for the current language
$localesPath = 'system/fields/calendar-locales/en.js';
if (is_file(JPATH_ROOT . '/media/system/js/fields/calendar-locales/' . strtolower($tag) . '.js'))
{
$localesPath = 'system/fields/calendar-locales/' . strtolower($tag) . '.js';
}
elseif (is_file(JPATH_ROOT . '/media/system/js/fields/calendar-locales/' . $tag . '.js'))
{
$localesPath = 'system/fields/calendar-locales/' . $tag . '.js';
}
elseif (is_file(JPATH_ROOT . '/media/system/js/fields/calendar-locales/' . strtolower(substr($tag, 0, -3)) . '.js'))
{
$localesPath = 'system/fields/calendar-locales/' . strtolower(substr($tag, 0, -3)) . '.js';
}

If you for whatever reason wanted to have separate configs for en-GB and en-US you'd still have to create en-gb.js and en-us.js in /media/system/js/fields/calendar-locales to let a template override take effect.

So you CAN override an existing file, but if you needed to add a new locale for whatever reason, you'd have to get it into the core directory first.

avatar infograf768
infograf768 - comment - 5 May 2018

So you CAN override an existing file, but if you needed to add a new locale for whatever reason, you'd have to get it into the core directory first.

I propose this:
It is possible to implement for a new language pack (that would not be available through J or which js files are not yet in core) the possibility to upload/get the specific files from media/xx-XX/js/fields/calendar-locales/ . These could also be used as overrides when they exist in core.

I have tested this for en-US and it works great:

		if (is_file(JPATH_ROOT . '/media/' . $tag . '/js/fields/calendar-locales/' . strtolower($tag) . '.js'))
		{
			$localesPath = $tag . '/fields/calendar-locales/' . strtolower($tag) . '.js';
		}

The advantage of such a solution is that it would not be deleted by a J update. It can be created manually or installed by a lang pack.

@mbabker @dgrammatiko
PR proposed here: #20303

avatar franz-wohlkoenig franz-wohlkoenig - change - 5 May 2018
Status Discussion Closed
Closed_Date 0000-00-00 00:00:00 2018-05-05 07:12:41
Closed_By franz-wohlkoenig
avatar joomla-cms-bot joomla-cms-bot - change - 5 May 2018
Closed_By franz-wohlkoenig joomla-cms-bot
avatar joomla-cms-bot joomla-cms-bot - close - 5 May 2018
avatar joomla-cms-bot
joomla-cms-bot - comment - 5 May 2018
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 5 May 2018

closed as having Pull Request #20303.

Add a Comment

Login with GitHub to post a comment