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

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).

Related

Load language file during joomla (2.5) system plugin installation

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!

Adding a user-defined language in Notepad++

I'm trying to add the syntax plugin for the Go programming language in Notepad++.
There is a repository for such user-defined languages. I downloaded and unzipped the Go files, which contained a README, a userDefinedLang_Go.xml, and go.xml.
I attempted to follow the instructions at the bottom of the page as follows. Since I am using Windows 7 (x64), my Notepad++ directory is "C:\Program Files (x86)\Notepad++".
Having not installed a user defined language before, I didn't have a userDefinedLang.xml file already, so I copied userDefinedLang_Go.xml into the root directory, and renamed it to remove the "_Go", making it userDefinedLang.xml.
I then copied go.xml into C:\Program Files (x86)\Notepad++\plugins\APIs\
This seems to be all of the steps necessary. However, when I open Notepad++, there is no "Go" near "Lang => User Defined", and there is no syntactic coloring on a .go file. Attempting to import via "View => User-Defined Dialogue => import" gives a "fail to import" error.
What am I doing wrong? I'm using a clean installation of Notepad++, which is version 6.1.8.
I had to put my userDefineLang.xml file in my AppData\Roaming folder:
C:\Users\[user]\AppData\Roaming\Notepad++
New install of Notepad++ 6.4.5 on Windows 7 64 bit
Download from Notepad++ site:
http://docs.notepad-plus-plus.org/index.php?title=User_Defined_Language_Files#G
Copy "go.xml" to C:\Program Files (x86)\Notepad++\plugins\APIs.
The default install doesn't have any user-defined languages, so you can do this:
Copy "userDefineLang_Go.xml" to C:\Users\\AppData\Roaming\Notepad++
Remove the "_Go" from the file name, so it's "userDefineLang.xml"
Uncomment the opening and closing "NotepadPlus" tags.
(If you already have a userDefineLang.xml then add the content from the _Go file.)
Restart Notepad++.
I just got it working on my system after some tinkering. Put this at the top of the userDefinedLang.xml file and the go.xml file:
<?xml version="1.0" encoding="Windows-1252" ?>
That should do the trick (after reopening Notepad++).
go.xml should be in the plugins/APIs folder, and userDefinedLang.xml goes in the root of Notepad++ as you said.
Something other answers do not discuss: Some older versions of Notepad++ do not appear to work with any of these answers.
I tried pretty much all the solutions before upgrading Notepad++ to version 6.4.2.
xkcd 979
Tested Notepad++ versions:
5.9 - not working - tested by namey
6.4.2 - working - tested by Elysian Fields
6.6.9 - working - tested by namey
For other versions your mileage may vary.
I share the solution I found for Notepad++ 6.5, because I had the same issue than the previous messages.
If not done, do the install steps explained in go\misc\notepadplus\README (userDefineLang.xml,functionList.xml,APIs).
When you don 't have useDefineLang.xml in Notepad++, create one using the file from go\misc\notepadplus\useDefineLang.xml, but don't forget to add the first line <?xml version="1.0" encoding="Windows-1252" ?>
and uncomment NotepadPlus part to have <NotepadPlus> at the beginning and </NotepadPlus> at the end.
Change in functionList.xml: <association ext=".go" id="go"/> BY <association userDefinedLangName="go" id="go"/>
As I didn't have any userDefineLang.xml file by default in Notepad++, I imported this file using the menu Language → Define your language → *Import.
Then stop/start Notepad++.
Check that Go is in the Language menu at the end of the list.
Open a .go file. If the color doesn't change automatically click on go in /Language menu
All were OK after that for me (indentation, color, autocompletion, etc.).
I added pl/sql language syntax to Notepad++. The syntax /language was on the web. Here's how I got it to work ...
Open the XML file using Notepad and added <?xml version="1.0" encoding="Windows-1252" ?> to the very beginning, as David had suggested. Then save it to userDefinedLang_plsql.xml
Paste the file in the Notepad++ root directory.
I also copied it into C:\Program Files (x86)\Notepad++\plugins\APIs\, and navigated to menu Languages → Userdefined, but it did nothing.
So, I then went to menu Languages → Define your language and selected pl/sql from the drop down, renamed it, and saved it in that dialog window.
The new language then it appeared in the language dialog at the end.
userDefineLang resides in C:\Users\username\AppData\Roaming\Notepad++\userDefineLang.xml.
Make sure your Notepad++ is installed under "C:\Program Files(86)", and not under "C:\npp.#.#.#.bin" folder.
And download from https://notepad-plus-plus.org/download. Or simply google "Download Notepad++".
Check out a sample Scala language userDefineLang.xml file here: https://github.com/nfang/scala-syntax-highlighter
If you don't have any user languages defined before, then after renaming userDefinedLang_Go.xml to userDefinedLang.xml, also edit the text of file by adding the tags <NotepadPlus></NotepadPlus> around the original content.

Applescript not accepting arRsync sdef commands?

I'm using the opensource GUI frontend for rsync called "arRsync". It works great, but there's no way to automate it.
What I'm trying to do is use Applescript to run a preset (which you define in the Application) using the following simple script:
tell application "arRsync" to runPreset "presetTest1"
The problem is Applescript thinks "runPreset" is a variable, not a command. I've also tried a tell/end-tell variation of the above, no dice. The 'runPreset' command is part of arRsync.sdef
You can find the arRsync project here
I've tried opening up both Info.plist files inside the app and ticking the 'Scriptable' box (or setting it to 'true' for those of you without Property List Editor) but I'm still stuck.
I'm a scripting noob when it comes to Cocoa :p help would be greatly appreciated
The arRsync binary is missing a scripting dictionary. Build from source, first making the following changes:
Edit Info.plist in the project, setting the "Scriptable" option to true.
Fix the project's script dictionary, arRsync.sdef. The code for the runPreset command has one letter too few (command codes must be two FourCCs, or eight characters, long). Add a character to runPreset's code attribute; just about any character will work. If you want, the file can be shortened and simplified by replacing the Standard and Text suites with an include. Back up the orignal file and make a new arRsync.sdef containing:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE dictionary SYSTEM "file://localhost/System/Library/DTDs/sdef.dtd">
<dictionary title="arRsync Terminology"
xmlns:xi="http://www.w3.org/2003/XInclude">
<xi:include href="file:///System/Library/ScriptingDefinitions/CocoaStandard.sdef"
xpointer="xpointer(/dictionary/suite)"/>
<suite name="arRsync Suite" code="arRs">
<command name="runPreset" code="runPPrst">
<cocoa name="runPreset" class="scriptController"/>
<direct-parameter type="any"/>
</command>
</suite>
</dictionary>
Alternatively, you could just replace the runPreset command element with the one from above.
Add arRsync.sdef to the "Copy Bundle Resources" phase of the arRsync target
Switch to a Release build ("Blackbeard" is the name for the debug build).
Build it.
That should produce a scriptable version of arRsync. As you've already figured out, you also might need to play with the target SDK.

poedit and xml files

How to configure poedit to extract strings from xml file?
I have Zend Framework navigation items in .xml like this:
<entry-i>
<label>Text to translate</label>
<params>
...
<params>
<entry-i>
And I want poedit to read just messages from <label>s.
I have been searching for a solution as well, and I have just gotten it to work!
In Poedit (I have 1.4.2), add a new parser (Edit > Preferences) with the following properties:
Language: XML
List of extensions separated by semicolons (e.g. .cpp;.h): *.xml
Parser command: xgettext --force-po -o %o %C %K %F -L glade
An item in keywords list: -k%k
An item in input files list: %f
Source code charset: --from-code=%c
In your translation project, add label and title to your keyword list and update the catalog.
The above advice to abuse the Glade extractor to parse non-Glade XML files is misguided. It’s never going to work well (case in point: some comments around here). Of course, it was better than nothing back in 2010.
Starting with gettext 0.19.7 (bundled with Poedit since 1.8.7), there’s a better way: there’s now builtin support in gettext for custom XML files via ITS rules.
The best way to extract strings from a custom XML file is to
Add a custom extractor with your extension, specifying standard gettext invocation, without the -L glade bit.
Write ITS rules for your file format.
Put them in the location of other .its and .loc files in Poedit’s installation.
For anyone running into problems with the configuration for Poedit on windows, specifically if you get an error message saying that glade and expat are not available, replace the supplied xgettext.exe with current one from the gnuwin32 project:
http://gnuwin32.sourceforge.net/packages/gettext.htm
You need to download the binaries and the dependencies. However, only the binary xgettext.exe must be extracted and related files (just run it and it will tell you what is missing)
Looks like PoEdit does not support XML yet.
I have created a little php script, to extract the labels to .php file,
which PoEdit does understand.
$xml = simplexml_load_file("../application/configs/navigation.xml")
or die("Error: Cannot open XML file");
echo '<?';
foreach($xml->xpath('//label') as $label){
echo 'echo _("'.$label.'");'. PHP_EOL;
}
It worked great!! I found the problem about "glade not supported" using Poedit 1.4.6 in Windows 7 but I fixed by downloading last gnuwin32 binaries and dependencies as user496209 said. Don't download the complet package because PoEdit comes with its own gettext library, so just donwload binaries and dependencies and replace the requested files into the poedit folder.

ant build.xml windows white space in path

I'm using Windows and I'm trying to get ANT to work.
When I do an ant build from the command line, I get:
C:\dev\Projects\springapp\${%ANT_HOME%}\lib not found.
I look into the build.xml file and I find:
appserver.home=${user.home}/apache-tomcat-6.0.14 (which I just copied and pasted straight from a tutorial)
I changed it to:
appserver.home="C:\Program Files\Apache Software Foundation\Tomcat 6.0"
but now I get:
C:\dev\Projects\springapp\"C:Program FilesApache Software FoundationTomcat 6.0"\lib not found.
It seems like the white space in Program Files and Tomcat 6.0 are causing the build to fail. How do you deal with these in xml files without re-creating the directory with a path with no white space?
Change it to
appserver.home="C:\\Program Files\\Apache Software Foundation\\Tomcat 6.0"
Variant with "/" instead "\" works on my system. Just need to delete " symbols before and after path structure.
Find the Windows short name for those directories using dir /x and use thme when setting path values.
Some more discussion at How does Windows determine/handle the DOS short name of any given file?
It looks like you have your properties setup incorrectly.
I'm guessing your basedir property is pointing at C:\dev\Projects\springapp and your properties are using value like:
<property name="property.1" value="directory" />
instead of
<property name="property.1" location="directory" />
Using the location property then resolves links as relative to your basedir if the location is a relative path and to the absolute path if you enter one of those. If you could post parts of your Ant file specifically how you define appserver.home and how you use it in the task that's throwing the error I could be more specific.
In addition to escaping the windows directory separator also make sure that all paths that you type in should be with correct capitalisation, Windows is not case sensitive but case presrving, while Ant is case sensitive.
In the top of your build.xml, try adding
<property environment="env"/>
and then using ${env.USER_HOME} (or whatever you have in your environment). That did it for me (${env.JAVA_HOME} rather than ${java.home}).

Resources