Making a language pack documentation

General questions regarding the use of languages in Joomla! 4.x.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10.
Locked
haitao
Joomla! Apprentice
Joomla! Apprentice
Posts: 32
Joined: Fri Mar 23, 2007 8:23 am

Making a language pack documentation

Post by haitao » Wed Sep 28, 2022 5:10 am

Hi!

I contacted the translation team in charge of that language and they said they were late so I can somehow wait for Joomla! stuff. I would however like to install the language pack without any translation (or English is fine).

I checked the files and the structure has changed between J!3.x and J!4.x. I found https://docs.joomla.org/J3.x:Making_a_L ... for_Joomla but nothing about version 4.

Can someone kindly guide me to make an initial pack so I can get the language available in Joomla! and translate my content?

Thank you.

SharkyKZ
Joomla! Hero
Joomla! Hero
Posts: 2886
Joined: Fri Jul 05, 2013 10:35 am
Location: Parts Unknown

Re: Making a language pack documentation

Post by SharkyKZ » Wed Sep 28, 2022 6:03 am

Main changes in J4 are that metadata XML file was renamed from [language-code].xml to langmetadata.xml and INI files are no longer prefixed with language code. Old file naming should still work until J5.

In theory, a language pack for the site part containing only 3 files should be enough to create a new content language. You would need just install.xml, langmetadata.xml and localise.php to get started.

Try the attached package. Rename all instances of xx-YY and xx_YY to your language code.
You do not have the required permissions to view the files attached to this post.

haitao
Joomla! Apprentice
Joomla! Apprentice
Posts: 32
Joined: Fri Mar 23, 2007 8:23 am

Re: Making a language pack documentation

Post by haitao » Wed Sep 28, 2022 6:39 am

Hi!

Thank you for your prompt answer. It almost works: the language is added, the content language too. But then when I create a new menu for that language and add a ..menu to it I am getting this error when saving after setting that menu to that language:
An error has occurred.
0 syntax error, unexpected token "-", expecting "{"

Setting the same menu to a different language doesn't do this.

Any idea what could be missing or mistyped?

Thank you.

SharkyKZ
Joomla! Hero
Joomla! Hero
Posts: 2886
Joined: Fri Jul 05, 2013 10:35 am
Location: Parts Unknown

Re: Making a language pack documentation

Post by SharkyKZ » Wed Sep 28, 2022 6:49 am

Class name in localise.php must use underscore instead of hyphen, e.g. En_GBLocalise.

haitao
Joomla! Apprentice
Joomla! Apprentice
Posts: 32
Joined: Fri Mar 23, 2007 8:23 am

Re: Making a language pack documentation

Post by haitao » Wed Sep 28, 2022 6:54 am

Yes! Thank you very much.

So now I looked at both J!3 and J!4 language pack. The files structure also seems different:
J!3 is like this:

Code: Select all

pkg_xx-YY.xml
admin_xx-YY.zip
site_xx-YY.zip
J!4 is like this:

Code: Select all

xx-YY (folder)
\- adminstrator (folder)
\- api (folder)
\- language (folder)
\- pkg_xx-YY.xml
and then all files are stored in language/xx-YY under each folder. api doesn't have a localise.php but the other 2 files are present.

I'm probably going to start using OmegaT and translation memory generated from J!3 translation to start generating J!4. I assume as the above worked, I just continue filling in the files inside that lang-xx-YY-site folder and everything will be ok?

You have been so helpful already.. thank you thank you!

SharkyKZ
Joomla! Hero
Joomla! Hero
Posts: 2886
Joined: Fri Jul 05, 2013 10:35 am
Location: Parts Unknown

Re: Making a language pack documentation

Post by SharkyKZ » Wed Sep 28, 2022 7:06 am

When making a package extension you can choose whether the included extensions are zipped or not. Either way should work.

To add installable files you need to declare them in the <files> section of install.xml file. Instead of declaring them individually you can use <folder> tag to add a whole directory. You can replace current <files> section with this to include all contents of the directory where install.xml is located:

Code: Select all

<files>
	<folder>/</folder>
</files>

haitao
Joomla! Apprentice
Joomla! Apprentice
Posts: 32
Joined: Fri Mar 23, 2007 8:23 am

Re: Making a language pack documentation

Post by haitao » Wed Sep 28, 2022 7:22 am

Great! So much information :-)

One last little thing: I made a custom php file to replace the default product page for a specific component. I added a line in English at this stage: how can I call a language override variable to store this sentence in different languages? Or is there better ways?

haitao
Joomla! Apprentice
Joomla! Apprentice
Posts: 32
Joined: Fri Mar 23, 2007 8:23 am

Re: Making a language pack documentation

Post by haitao » Thu Sep 29, 2022 4:26 am

Code: Select all

<?php echo JText::_('TEXT_VARIABLE'); ?>
Answering to my own question if ever someone is also wondering.

Thank you.


Locked

Return to “Language - Joomla! 4.x”