Load language file during joomla (2.5) system plugin installation - joomla

I'm having a real hard time showing a localized string during the installation of a system plugin (in Joomla 2.5). The "normal" way with localized strings in the xml file doesn't seem to work, (see this other question: Language based installation description).
I now tried the way proposed there, to show the description via the install scripts. This kind of works (I can echo text successfully), however, I also can't localize there - when debugging the language it shows that the plugin.sys.ini is not loaded yet; I tried to manually load the file, but had no success with loading any of my plugin language files.
This is what I got so far (in a file named setupscripts.php):
<?php // no direct access
defined('_JEXEC') or die('Restricted access');
class plgsystemmyplgnameInstallerScript {
static function loadLanguage() {
$lang =& JFactory::getLanguage();
$lang->load('plg_system_myname', JPATH_ADMINISTRATOR);
}
function install($parent)
{
self::loadLanguage();
echo JTEXT::_("PLG_MYNAME_TEST_TEXT");
}
function uninstall($parent)
{
self::loadLanguage();
echo JText::_('PLG_MYNAME_UNINSTALL_TEXT');
}
function update($parent)
{
self::loadLanguage();
echo JText::_('PLG_MYNAME_UPDATE_TEXT');
}
function preflight($type, $parent) {}
function postflight($type, $parent) {
self::loadLanguage();
echo JText::_('PLG_MYNAME_INSTALL_TEXT');
}
}
But I only get ??PLG_MYNAME_TEST_TEXT?? ??PLG_MYNAME_INSTALL_TEXT?? (language debugging is turned on) during installation... weirdly enough, the language debug feature at the bottom of the page under "untranslated strings" shows "None" (where do the question marks then come from if not from a tried but failed translation???).
Tried some variations of it (with .sys at the end of the plugin name, since I actually think the setup strings should be in the .sys.ini file, without the second parameter (leaving it default), but no luck - no error, nothing in the log (in fact my log file isn't existing, probably there was no entry yet? can one set the log level with Joomla?). But never is there any file loaded (nothing changes under "loaded language files".
Anybody got an idea how to load the language properly?
Is there something special to consider when loading languages during setup? Why is there no error message if loading the languages fails? Do I maybe have to install the language files to a special location to get them recognized during installation? My current xml looks like this:
<extension version="2.5" type="plugin" group="system" method="upgrade">
<name>PLG_MYNAME</name>
<!-- ... author, copyright, version, .. -->
<scriptfile>setupscripts.php</scriptfile>
<files>
<filename plugin="myname">myname.php</filename>
<filename>setupscripts.php</filename>
<filename>index.html</filename>
<folder>sql</folder>
</files>
<!-- ... install->sql->file ... -->
<!-- ... uninstall->sql->file ... -->
<!-- ... update->schemas->schemapath ... -->
<languages [folder="admin"]>
<language tag="en-GB">en-GB.plg_system_myname.ini</language>
<language tag="en-GB">en-GB.plg_system_myname.sys.ini</language>
<!-- ... other languages ... -->
</languages>
<!-- ... config->fields->fieldset->field ... -->
</extension>
(the square brackes around folder="admin" are supposed to indicate that I tried both with and without this attribute. It doesn't change anything).

It only works on installation if you also copy the files to the admin language folder. If you look at the core extensions you will see that they do both. It's really a bug but that's the work around.

Finally I found out how to really do it. A thorough search in the google Joomla dev group brought up this very similar question.
Basically, the language files need to reside in a separate language folder it seems, and the files section also needs to reference them. My xml now looks like this:
<!-- ... everything else stayed the same, except: -->
<files>
<filename plugin="myplg">myplg.php</filename>
<filename>index.html</filename>
<folder>language</folder>
<folder>sql</folder>
</files>
<languages folder="language">
<language tag="en-GB">en-GB/en-GB.plg_system_myplg.ini</language>
<language tag="en-GB">en-GB/en-GB.plg_system_myplg.sys.ini</language>
<!-- .. other languages ... ->
</languages>
<!-- ... rest of the xml file ... -->
The language files are now all in separate subfolders... they get copied to the exact same location as before (administrator/language//...), but now the description from the XML is also localized!
I find it very weird that there are so many ways to specify language files, which all basically work except for the one corner case of the installation...
Hope this will help other people struggling with this!

Related

How to properly structure UWP app icons in AppxManifest.xml file for a Win32 app converted using Desktop Bridge (Project Centennial)

I'm trying to convert my Win32 app into a UWP app using Project Centennial converter (i.e. Desktop bridge.)
After the app is converted, I need to adjust AppxManifest.xml file to ensure the following:
That all icon formats are configured properly.
That I properly specified app resources for: English (US), German, French and Russian languages.
So I followed this Windows 10 icon guide and created the following .png images that were all placed into the Assets folder. I got these:
And my AppxManifest.xml was structured as such:
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" xmlns:uap2="http://schemas.microsoft.com/appx/manifest/uap/windows10/2" xmlns:uap3="http://schemas.microsoft.com/appx/manifest/uap/windows10/3" xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" xmlns:desktop="http://schemas.microsoft.com/appx/manifest/desktop/windows10">
<Identity Name="MyApp.Name" ProcessorArchitecture="x86" Publisher="CN=My Name, O=My Name, STREET="Street Address", L=City, S=State, PostalCode=12345, C=US" Version="1.2.3.4" />
<Properties>
<DisplayName>MyApp.Name</DisplayName>
<PublisherDisplayName>PublisherName</PublisherDisplayName>
<Logo>Assets\StoreLogo-50x50.png</Logo>
</Properties>
<Resources>
<Resource Language="en-us" />
<Resource Language="de-DE" />
<Resource Language="fr-FR" />
<Resource Language="ru-RU" />
</Resources>
<Dependencies>
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.14342.0" MaxVersionTested="10.0.14342.0" />
</Dependencies>
<Capabilities>
<rescap:Capability Name="runFullTrust" />
</Capabilities>
<Applications>
<Application Id="MyApp.Name" Executable="VFS\Users\ContainerAdministrator\AppData\Local\PublisherName\App Name\RunFile.exe" EntryPoint="Windows.FullTrustApplication">
<uap:VisualElements DisplayName="My App Name" Description="My app does this ... and this ..."
BackgroundColor="#aabbcc"
Square71x71Logo="Assets\AppNameSmallTile.png"
Square150x150Logo="Assets\AppNameMedTile.png"
Square310x150Logo="Assets\AppNameWideTile.png"
Square310x310Logo="Assets\AppNameLargeTile.png"
Square44x44Logo="Assets\AppNameAppList.png"
>
<uap:DefaultTile>
<uap:ShowNameOnTiles>
<uap:ShowOn Tile="square150x150Logo" />
<uap:ShowOn Tile="Square310x150Logo" />
<uap:ShowOn Tile="Square310x310Logo" />
</uap:ShowNameOnTiles>
</uap:DefaultTile>
</uap:VisualElements>
<Extensions />
</Application>
</Applications>
</Package>
So can someone answer these questions:
I'm somewhat confused about specifying icons for correct sizes and scaling. Did I do it correctly?
Do I need to specify scaling for Assets\StoreLogo-50x50.png icon as well?
And lastly, did I specify resources for 4 different languages correctly?
EDIT: While waiting, I tried compiling my AppxManifest.xml above with the assets I showed. But makeappx.exe tool gives me the following error:
MakeAppx : error: Error info: error C00CE015: App manifest validation
error: The app manifest must be valid as per schema: Line 22, Column
27, Reason: The attribute 'Square71x71Logo' on the element
'{http://schemas.microsoft.com/appx/manifest/uap/windows10}VisualElements'
is not defined in the DTD/Schema.
It evidently doesn't like the following icon sizes:
Square71x71Logo
Square310x150Logo
Square310x310Logo
But then even if I remove the icon sizes above from AppxManifest.xml, when I try to pack it with the following command:
"C:\Program Files (x86)\Windows Kits\10\bin\x64\makeappx.exe" pack /d "path-to-folder-to-pack" /p "path-to\MyAppxPackage.appx"
I get the following errors about naming assets for scaling:
MakeAppx : error: Manifest validation error: Line 22, Column 27,
Reason: The file name "Assets\AppNameMedTile.png" declared for element
"[local-name()='Applications']/[local-name()='Application']/[local-name()='VisualElements']"
doesn't exist in the package. If this file has multiple variations or
resource versions for language, scale, contrast, etc., use the /l
command line option to disable this validation. MakeAppx : error:
Manifest validation error: Line 23, Column 27, Reason: The file name
"Assets\AppNameAppList.png" declared for element
"[local-name()='Applications']/[local-name()='Application']/[local-name()='VisualElements']"
doesn't exist in the package. If this file has multiple variations or
resource versions for language, scale, contrast, etc., use the /l
command line option to disable this validation. MakeAppx : error:
Package creation failed. MakeAppx : error: 0x80080204 - The specified
package format is not valid: The package manifest is not valid.
Using suggested /l command as such:
"C:\Program Files (x86)\Windows Kits\10\bin\x64\makeappx.exe" pack /l /d "path-to-folder-to-pack" /p "path-to\MyAppxPackage.appx"
builds the package with a lot of warnings. But when I install it later, all icons in it seem to be blank.
There must be something that I'm missing here?
I see two main problems: you're defining tile images in the wrong place, and you don't talk at all about a resources.pri file.
The UAP schema is fairly involved, but also reasonably well documented, so make sure you respect its requirements. In particular, the uap:VisualElements element only has the image attributes Square150x150Logo and Square44x44Logo. If you want to define other sizes, they go in attributes on a child uap:DefaultTile element. Note that your uap:ShowOn elements' attributes include an incorrect Square310x150Logo that should instead be wide310x150Logo.
Once you sort that out, makeappx should succeed with your original command line, i.e., without the additional /l parameter. However this is not enough to make your alternate DPI images show up. For that you will need to create a resources.pri file. You can do this manually by using makepri.exe to create a template priconfig.xml, update it, then invoke makepri again to build the resources.pri from it.
Alternately, use a tool that will create an app package with a resources.pri for you (such as Visual Studio), and extract the resources.pri and add it to your package. Just make sure the locations you use in your package match the ones in the package created by the tool, as relative paths are stored in the resources.pri file. (As a bonus, you can look at the AppxManifest.xml that this creates to verify that your structure from the first part is correct. Just don't forget that apps using the desktop bridge will have additional namespaces and capabilities that Visual Studio won't offer.)

language file in joomla is not working properly?

http://127.0.0.1/COM/administrator/index.php?option=com_process_name
when i click on my newly created component form components menu "com_process_name" should be translated from language.ini file but joomla 3.1 is not translating that file properly as shown above.
my com.process.sys_language.ini file
COM_PROCESS_NAME="Hello World"
but when I watch it from extension Manager->manage it shows its proper name Hello World
I am using JOOMLA 3.1.5
my manifest file
<extension type="component" version="3.1" method="upgrade">
<name>COM_PROCESS_NAME</name>
<author>Arslan Tahir</author>
<creationDate>25 DEC 2013</creationDate>
<copyright>GPL</copyright>
thats how i am including language file
<languages folder="components/com_process">
<language tag="en-GB">en-GB/en-GB.com_process.ini</language>
<language tag="en-GB">en-GB/en-GB.com_process.sys.ini</language>
</languages>
The URl used to view your component such as:
index.php?option=com_process_name
is generated by the component name com_process_name which cannot be translated. Anywhere else on Joomla, it can be

Joomla! 2.5 language file - cannot translate description into xml-File

I checked out the question here: Joomla! 2.5 language file - translate description
It is exact the problem I have but unfourtunately I cannot answer the commen from Valentin. So here is my Problem again:
In my xml-File I have this line:
<description>COM_MYCOMPONENT_DESCRIPTION</description>
And in the file en-GB.com_mycomponent.sys.ini I have this:
COM_MYCOMPONENT="MyComponent"
COM_MYCOMPONENT_DESCRIPTION="This is the myComponent description"
COM_MYCOMPONENT_SUMMARY="Summary"
But in Debug-Mode for Languages I have every time this result:
??COM_MYCOMPONENT_DESCRIPTION??
Any Ideas?
Björn
You are using the language file correctly, therefore I am under the impression that it's due to the location of the file. Make sure you have the following in your XML file:
<languages folder="language">
<language tag="en-GB">en-GB/en-GB.com_mycomponent.ini</language>
<language tag="en-GB">en-GB/en-GB.com_mycomponent.sys.ini</language>
</languages>
Also take note of the location:
I have used folder="language" then used en-GB before the file name so the folder structure will be like so:
root(where the XML is)/language/en-GB/en-GB.com_mycomponent.sys.ini
You don't have to put your language files in both places.
Your first configuration is actually correct and is working on Joomla 3.3 for sure.
In your manifest file you should have the language files declares as
<administration>
....
<folder>language</folder>
.....
</administration>
and dont make use of
<languages>....</languages>
Also on your package the folder structure should be
admin/language/en-GB/en-GB.yourcomponent.sys.ini.
If you have this configuration already, you are correct.
In that case from the message of the language debug mode, I assume that you either have mispeled something or there is an error inside your language file.
The latter is what usually happens with me. For example many times I have this error:
COM_MYCOMPONENT_TRA="A translation string"
COM_MYCOMPONENT_ANOTHER_ONE="Another one"
COM_MYCOMPONENT_SOMEOTHER=Some othen translation string"
COM_MYCOMPONENT_MORE="One more "
COM_MYCOMPONENT_LAST_ONE="E translation string"
(Missing the first double quote on the third line).

Joomla! 2.5 language file - translate description

I create a new plugin for joomla 2.5, and in xml i use:
<description>PLG_VAR_DESC</description>
But when install, he dont show the the translation but the var on file.
<languages folder="">
<language tag="en-GB">en-GB.plg_system_name.ini</language>
<language tag="en-GB">en-GB.plg_system_name.sys.ini</language>
</languages>
<files>
<folder>images</folder>
<filename>index.html</filename>
<filename>parameters.xml</filename>
<filename plugin="plg_name">plg_name.php</filename>
</files>
I try everything but i cant put this work..
Thanks
Under the administrator panel in Joomla! you can find under Site - Global configuration - System:
This will allow you to see the Joomla! Debug console:
There you can see if the language file your are using is loaded. If it's not loaded, than your manifest file is not consistent.
I think that the problem could be solved with:
<languages folder="admin">
instead of
<languages folder="">
Also for your reference, the Joomla! documentation on "Specification of language files" may be a good read.
I found the problem.. is the name of language file. Thank's for helping me

Is it possible to pass variable to WIX localization file?

I need to use variable in WIX localization file WIXUI_en-us.wxl.
I tried use it like this:
<String Id="Message_SomeVersionAlreadyInstalled" Overridable="yes">A another version of product $(var.InstallationVersionForGUI) is already installed</String>
But it doesn't work. And when I declared property and used it this way:
<String Id="Message_SomeVersionAlreadyInstalled" Overridable="yes">A another version of product [InstallationVersionForGUI] is already installed</String>
doesn't work either.
Where was I wrong?
Thanks for help and your time.
Localization strings are processed at link time, so you can't use $(var) preprocessor variables. Using a [property] reference is supported, as long as the place where the localization string is used supports run-time formatting (e.g., using the Formatted field type).
Your second method should work just fine. This is the same method used by the default .wxl files.
For example, in your .wxl file you would declare your string:
<String Id="Message_Foo">Foo blah blah [Property1]</String>
And in your .wxs file, you declare the property. If you wish, you can declare the property to match a WiX variable (which it sounds like you're trying to do)
<Property Id="Property1">$(var.Property1)</Property>
I was trying to get localization file to use variables. Came across this post:
There are different layers of variables in WiX (candle's preprocessor
variables, Light's WixVariables/localization variables/binder
variables, and MSI's properties). Each have different syntax and are
evaluated at different times:
Candle's preprocessor variables "$(var.VariableName)" are evaluated
when candle runs, and can be set from candle's commandline and from
"" statements. Buildtime environment
properties as well as custom variables can also be accessed similarly
(changing the "var." prefix with other values).
Light's variables accessible from the command-line are the
WixVariables, and accessing them is via the "!(wix.VariableName)"
syntax. To access your variable from your commandline, you would need
to change your String to: This build was prepared on
!(wix.BuildMachine)
If you instead need to have the BuildMachine value exist as an MSI
property at installation time (which is the "[VariableName]" syntax)
you would need to add the following to one of your wxs files in a
fragment that is already linked in:
Now, the environment variable COMPUTERNAME always has held the name of
my build machines in the past, and you can access that this way:
$(env.COMPUTERNAME). So, you can get rid of the commandline addition
to light.exe and change your wxs file like this:
<WixProperty Id="BuildMachine" Value="$(env.COMPUTERNAME)"/>
Preprocessor variables $(var.VariableName) are are processed at link time, so ideally you would use [PropertyName] which would be defined on the main Product element.
The issue sometimes is that property is not yet defined, for instance using the product name on the localization file seems not posible.
This solution was done aiming to only type the product name once given "Super product" as product name:
In case of running through visual studio extension:
Project properties -> Build -> Define variables -> "MyProductName=Super product" (No quotes)
In case of runing from cmd or some other place:
On Light.exe, add -d"MyProductName=Super product"
Into the localization .wxl file:
<String Id="Description" Overridable="yes">Description of !(wix.MyProductName)
to make it more interesting</String>
I have an aditional config file .wxi I include on other files to have some vars, for instance, here i had hardcoded the value but now it's harcoded on the variable definition and I use the given value:
<?xml version="1.0" encoding="utf-8"?>
<Include>
<!-- Define the product name preprocesor variable -->
<?define ProductName="!(wix.ProductNameDefVar)" ?>
<!-- From this point, can use the preprocesor var -->
<?define ProductName_x64="$(var.ProductName) (64bit)" ?>
<?define ProductName_x32="$(var.ProductName) (32bit)" ?>
<?define CompanyDirName = "My company name" ?>
</Include>
Finally, the place where the localization value where the localization text was not interpolating, is like this:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<!-- Include the config file with the preprocesor var -->
<?include $(sys.CURRENTDIR)\Config.wxi?>
<!-- Main product definition -->
<Product Id="$(var.ProductCode)"
Name="$(var.ProductName)"
Language="!(loc.Language)"
Version="$(var.BuildVersion)"
Manufacturer="!(loc.Company)"
UpgradeCode="$(var.UpgradeCode)">
<!-- Package details -->
<!-- Here, Description was not interpolating -->
<Package InstallerVersion="200"
Compressed="yes"
InstallScope="perMachine"
Platform="$(var.Platform)"
Manufacturer="!(loc.Company)"
Description="!(loc.Description)"
Keywords="!(loc.Keywords)"
Comments="!(loc.Comments)"
Languages="!(loc.Language)"
/>
[...]

Resources