How to get the language specific messages using google closure template - closures

Am trying to implement internationalization support to my project for this people suggested google Closure Templates.but am very new to closure templates.am trying to get the language specific messages using closure template but am not getting in xlf file.If any one knows how to generate language specific messages using closure template, please tell me the steps.that's great help to me.
My .soy file code as bellow.
{namespace poc}
/**
*Testing message translation
*#param pageTitle
*/
{template .translate}
<HTML>
<Head>
<title>{$pageTitle}
</title>
</head>
<div>
{msg desc="Hello"}Hello{/msg}
</div>
</html>
{/template}
and generated .xlf content as bellow
<?xml version="1.0" encoding="UTF-8"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file original="SoyMsgBundle" datatype="x-soy-msg-bundle" xml:space="preserve" source-language="en" target-language="pt-BR">
<body>
<trans-unit id="2286494898080570401" datatype="html">
<source>Thanks</source>
<target/>
<note priority="1" from="description">Says thanks</note>
</trans-unit>
</body>
</file>
</xliff>

I see you already used the SoyMsgExtractor to create the base xlf. Next you need to make translations of this base xlf to the languages you want to support. A file for each language is created. I used the xliff exitor from Translution. http://sourceforge.net/projects/eviltrans.
Next, using the SoyToJsSrcCompiler a translation soy can be made per language:
java -jar SoyToJsSrcCompiler.jar --shouldGenerateGoogMsgDefs --bidiGlobalDir 1 --messageFilePathFormat Filename_en-us.xliff --outputPathFormat FileName_fr.js *.soy
This will create a Filename._fr.js file that contains the compiled soy file.
Including this file instead of the original soy (or compiled) will create a localized version.
Good luck!
\Rene

i think the easiest way is to make (i.e. generate from whatever source) a separate js file which contains one messages object and reference it through an extern declared function.
it justs works and has no complicated dependencies.

Related

What is the structure of wikipedia dumps?

I need the list of Hungarian words for a project and the only possible source I found is wikipedia XML dumps. They are really big, I guess I could parse them with a read stream and a SAX parser, but it would be nice to know more about the structure so I could test the code on a small example before running it on the big files. Is there a description somewhere about what structure they use and what the different XML gzip files contain? https://dumps.wikimedia.org/enwiki/latest/ https://dumps.wikimedia.org/huwiki/latest/
The format is documented here: https://www.mediawiki.org/wiki/Help:Export It looks like this:
<mediawiki xml:lang="en">
<page>
<title>Page title</title>
<restrictions>edit=sysop:move=sysop</restrictions>
<revision>
<timestamp>2001-01-15T13:15:00Z</timestamp>
<contributor><username>Foobar</username></contributor>
<comment>I have just one thing to say!</comment>
<text>A bunch of [[Special:MyLanguage/text|text]] here.</text>
<minor />
</revision>
<revision>
<timestamp>2001-01-15T13:10:27Z</timestamp>
<contributor><ip>10.0.0.2</ip></contributor>
<comment>new!</comment>
<text>An earlier [[Special:MyLanguage/revision|revision]].</text>
</revision>
</page>
<page>
<title>Talk:Page title</title>
<revision>
<timestamp>2001-01-15T14:03:00Z</timestamp>
<contributor><ip>10.0.0.2</ip></contributor>
<comment>hey</comment>
<text>WHYD YOU LOCK PAGE??!!! i was editing that jerk</text>
</revision>
</page>
</mediawiki>

Add translation to TYPO3 Extension via Typoscript

is there a way to substitute/override the default de.locallang.xlf of the extension via Typoscript? I want to change the text of mindshape_cookie_hint in a way that will survive an update.
If it is a plugin you can override translations in TypoScript via _LOCAL_LANG which is also what mindshape_cookie_hint suggests in its docs, for example:
plugin.tx_myext_pi1._LOCAL_LANG.de.list_mode_1 = Der erste Modus
This requires you to manage your translation strings in TypoScript though which is far from ideal.
A better and more general solution is registering custom translations via locallangXMLOverride. This allows you to manage these translations just like everywhere else.
From the documentation:
ext_localconf.php:
$GLOBALS['TYPO3_CONF_VARS']['SYS']['locallangXMLOverride']['EXT:cms/locallang_tca.xlf'][] =
'EXT:examples/Resources/Private/Language/custom.xlf';
$GLOBALS['TYPO3_CONF_VARS']['SYS']['locallangXMLOverride']
['de']['EXT:news/Resources/Private/Language/locallang_modadministration.xlf'][] = 'EXT:examples/Resources/Private/Language/Overrides/de.locallang_modadministration.xlf';
The first line shows how to override a file in the default language, the second how to override a German ("de") translation. The German language file looks like this:
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<xliff version="1.0">
<file source-language="en" datatype="plaintext" original="messages" date="2013-03-09T18:44:59Z" product-name="examples">
<header/>
<body>
<trans-unit id="pages.title_formlabel" xml:space="preserve">
<source>Most important tile</source>
<target>Wichtigster Titel</target>
</trans-unit>
</body>
</file>
</xliff>
You are looking for this https://wiki.typo3.org/TypoScript_language_additions,_override
As written by Ghanshyam Bhava in his answer, you can just take a look at
the locallang.xlf file in the plugin folder in the file system to have an overview of the keys the extension uses and then write in your TypoScript template:
plugin.tx_exampleplugin_pi1._LOCAL_LANG.it {
key1 = value1
key2 = value2
...
}
see also https://docs.typo3.org/typo3cms/TyposcriptReference/Setup/Plugin/Index.html#local-lang-lang-key-label-key
In a general way, correct me if I am wrong, I think that you have modified the original .xlf file of the plugin; this procedure is not recommended for the reason you are facing: an update would delete your changes.
A good way to deal with this problem could be for example using the extension EXT:lfeditor (https://extensions.typo3.org/extension/lfeditor/); read carefully its manual.
Another source (official documentation): https://docs.typo3.org/typo3cms/CoreApiReference/latest/ApiOverview/Internationalization/ManagingTranslations.html?highlight=locallangxmloverride#custom-translations
I'll take an excerpt from that page:
The $GLOBALS['TYPO3_CONF_VARS']['SYS']['locallangXMLOverride'] allows to override both locallang-XML and XLIFF files. Actually this is not just about translations. Default language files can also be overridden. In the case of XLIFF files, the syntax is as follows (to be placed in an extension's ext_localconf.php file):
$GLOBALS['TYPO3_CONF_VARS']['SYS']['locallangXMLOverride']['EXT:cms/locallang_tca.xlf'][] = 'EXT:examples/Resources/Private/Language/custom.xlf';
$GLOBALS['TYPO3_CONF_VARS']['SYS']['locallangXMLOverride']['de']['EXT:news/Resources/Private/Language/locallang_modadministration.xlf'][] = 'EXT:examples/Resources/Private/Language/Overrides/de.locallang_modadministration.xlf';
The first line shows how to override a file in the default language, the second how to override a German ("de") translation. The German language file looks like this:
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<xliff version="1.0">
<file source-language="en" datatype="plaintext" original="messages" date="2013-03-09T18:44:59Z" product-name="examples">
<header/>
<body>
<trans-unit id="pages.title_formlabel" xml:space="preserve">
<source>Most important tile</source>
<target>Wichtigster Titel</target>
</trans-unit>
</body>
</file>
</xliff>
With below typoscript you can overwrite individual translations for TYPO3 Extension:
plugin.tx_myPlugin_pi1._LOCAL_LANG.de.key = value;
plugin.tx_myPlugin_pi1._LOCAL_LANG.en.key = value;
Generally common for every extension. Hope this will help you!
Greetings!

How do I get IDE code completion to work with JSF 2.2 non-composite component attributes?

Problem: I get code completion on the tags but not the attributes.
I am working on a new web application using
Java 8
JSF 2.2.14
PrimeFaces 6.1
Netbeans 8.2
We are using a library that is provided to us in JavaScript (generated from Typescript sources). I have written a non-composite component to wrap this library and keep all that JavaScript code hidden and in one place. It initializes the the library and provides attributes to pass JavaScript callback functions to the library (so we still have to write some JavaScript).
snippet from the JSF .xhtml file
<script type="text/javascript">
function jscallbackHandler() { alert("function called!");}
</script>
<myComponent:initialize callback1="jscallbackHandler" />
This tag invokes my class to write a lot of JavaScript into the page to setup and initialize the library.
I am using the #FacesComponent annotation to declare my classes as custom components.
snippet from 'InitMyComponent.java' file
#FacesComponent(createTag = true,
tagName = "initialize",
namespace = "https://com.my.project/myComponent",
value = InitMyComponent.FAMILY)
public class InitMyComponent extends UIComponentBase { ... }
This is working except for IDE code completion and I can't find documentation or examples for JSF 2.2 components that show how to declare attributes and hook them into the project. I have seen many examples of earlier JSF 2.x components that use a taglib.xml to define the attributes for code completion, but it seems to be 'at odds' with features of the JSF 2.2 style annotation. I have to remove most of the attributes of the annotation (basically revert to a JSF 2.0 style annotation) or I get "Expression Error: Named Object ... not found". I have also gotten Tag Library supports namespace, but no tag was defined for name. If I just provide a component name to the annotation that matches the one in the taglib file it works, but just no code completion.
I have a FACELETS_LIBRARIES name/value pair in a context-param tag in the web.xml to declare where my facelet-taglib file is located.
snippet from the 'web.xml' file
<!-- Enable IDE autocompletion on component attributes -->
<context-param>
<param-name>javax.faces.FACELETS_LIBRARIES</param-name>
<param-value>/WEB-INF/myComponent.taglib.xml</param-value>
</context-param>
I have a facelet-taglib file named 'myComponent.taglib.xml' in my WEB-INF directory (same place as faces-config.xml and web.xml).
UPDATE: Responding to the comment by Kukeltje, I updated my facelet-taglib file to version 2.2, but I still get "No Suggestions" from my IDE... also updated the namespaces in my .xhtml JSF source file (even though this site said the older versions were still supported
https://jsflive.wordpress.com/2013/05/16/jsf22-namespaces/)
snippet from the 'myComponent.taglib.xml' file
<?xml version="1.0"?>
<facelet-taglib version="2.2"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-facelettaglibrary_2_2.xsd">
<namespace>http://java.sun.com/jsf/composite/components</namespace>
<composite-library-name>myComposites</composite-library-name>
<namespace>https://com.my.project/myComponent</namespace>
<tag>
<tag-name>initialize</tag-name>
<component>
<component-type>InitMyComponent</component-type>
</component>
<attribute>
<name>callback1</name>
<required>false</required>
<type>java.lang.String</type>
</attribute>
</tag>
The faces-config.xml file - defines the javaee and schema namespaces, and version 2.2 but it is otherwise 'empty'.
<?xml version="1.0" encoding="UTF-8"?>
<faces-config
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd"
version="2.2">
</faces-config>
I am fine with having to type in all the attributes but I just can't seem to find the proper way to hook this feature into my project.
Note: I have experimented with using a composite component. The code completion for attributes worked, but then I lost code completion for the tags. I'm just writing out JavaScript to setup and call a JavaScript library's initialize function but also, I would really love to pass a JavaScript object back to a bean on the server when my callback function is invoked. I am currently using a BalusC provided solution that involves p:remoteCommand and updating hidden input fields. I would greatly prefer to provide reference to the bean using EL in an attribute of my custom component.

How to extend felogin's locallang?

How is it possible to add translations of strings to the felogin plugin? I slowly start to get the convention for templates (directing to the modified templates in the plugin's typoscript configuration) but that does not work with the locallang. The original messages are in English in the xlf format, located in the plugin's folder. I know this can be done in TypoScript but I do not like to have the strings defined so incosistently. (I guess modifying that original file is not the proper way.)
Overriding labels by TypoScript is the way to go. Manually editing the l10n files is a really bad idea - these files are overwritten on updating the translations. If the extension gets an update and new labels are added, you will want to perform the updates.
The change from XML files for translation to the XLIFF format didn't change anything in the best practise you should use for adjusting labels according to your needs. It's just another format with a standardized translation server (Pootle) that (in theory) allows some special features like e.g. plural forms.
Conclusion: Use TypoScript.
For the default language (no config.language set) use:
plugin.tx_felogin_pi1._LOCAL_LANG.default {
key = value
}
For a specific language, e.g. German, use
plugin.tx_felogin_pi1._LOCAL_LANG.de {
key = value
}
The best way is to use the following code:
ext_tables.php, e.g. of your theme extension with
$GLOBALS['TYPO3_CONF_VARS']['SYS']['locallangXMLOverride']['EXT:felogin/Resources/Private/Language/locallang.xlf'][] = 'EXT:theme/Resources/Private/Language/locallang_felogin.xlf';
and in this file you can use something like
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<xliff version="1.0">
<file source-language="en" datatype="plaintext" original="messages" date="2015-06-30T21:14:27Z">
<header>
<description>Language labels for felogin</description>
</header>
<body>
<trans-unit id="permalogin">
<source>An diesem Rechner angemeldet bleiben</source>
</trans-unit>
<trans-unit id="ll_forgot_header">
<source>Passwort vergessen?</source>
</trans-unit>
<trans-unit id="ll_welcome_header">
<source>Sie betreten den Händlerbereich</source>
</trans-unit>
<trans-unit id="ll_welcome_message">
<source>Bitte loggen Sie sich ein.</source>
</trans-unit>
</body>
</file>
</xliff>
You can use the BE language module to download preconfigured locallangs for every language you need.
The files are stored in e.g. typo3conf/l10n/de/fe_login.
You can edit these files manually in l10n to get your own strings inside or use an extension like snowbabal to do the editing inside a BE module.

Set the Document Template of a Document Library programmatically

I am creating a Document Library from an event receiver. I would like to change the Document Library to a custom Word document. In the user interface, this is simply done by changing the Template URL value in the Document Template property under Document Library Advanced Settings. I'm not sure how to do this via code.
I would also be open to creating a list template with my document template already setup, but I'd prefer to go the other route so I retain the flexibility of setting up each document library with a different template.
Thanks.
Specify it within your content type definition in the elements.xml for the feature and add a module file reeference.
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<ContentType ID="0x010100DC863B72929F8148A8A84BF932C5356701"
Name="Word 2007"
Group="CEO Content Types"
Sealed="FALSE"
FeatureId="332a1967-3ae1-498b-ba11-f03743cab20b">
<FieldRefs />
<DocumentTemplate TargetName="Untitled.docx"/>
</ContentType>
<Module Name="WordDefaultFile" Url="_cts/MyWord" RootWebOnly="TRUE">
<File Url="Untitled.docx" Name="Untitled.docx" Type="Ghostable"></File>
</Module>
</Elements>
Copy the template to your feature directory and add an ElementFile reference to it within the ElementsManifest section of your feature.xml.
<ElementManifests>
<ElementManifest Location="MyWord-CT.xml" />
<ElementFile Location="Untitled.docx"/>
</ElementManifests>
</Feature>

Resources