we just started using ext:forms in an extbase action fluid template with the viewhelper (with persistenceIdentifier option). In general this works really fine so far. Also the translation for the form elements works fine, so all labels are in german (german is default language - no other languages). The only problem is the Confirmation finisher.
My configuration looks like this:
identifier: Confirmation
options:
message: 'Thank you!'
contentElementUid: ''
And I use the same xlf file as for the other labels. But it always uses the english text from xlf file (so this means the key is spelled correct etc.).
So what can I do, that the finisher also uses the correct frontend language?
I had the same problem today.
you can add your specific key in a template file and override it there. Here the translation works.
In your CustomFormSetup.yaml you need to set an extra prototype based on your standard prototype and add a new template path:
eventRegistration:
__inheritances:
10: 'TYPO3.CMS.Form.prototypes.standard'
finishersDefinition:
Confirmation:
options:
templateName: 'Confirmation'
templateRootPaths:
50: 'EXT:YOUR-EXT-KEY/Resources/Private/Templates/Default/Form/Finishers/Confirmation/YOUR-SUB-FOLDER/'
The File needs to be named Confirmation.html
<f:translate key="LLL:EXT:YOUR-EXT-KEY/Resources/Private/Language/Default/locallang.xlf:FORM- KEY.finisher.Confirmation.message"/>
That way you keep your native Confirmation Message Handling but override it for the one that needs to be translated.
Also dont forget to add the prototype type you just created to your yourForm.form.yaml
prototypeName: yourFormPrototype
Related
I am creating a template in Wikipedia to link articles to an external website which is a book archive called fadedpage.com. I am generating a url to link to a specific author page. Part of the url is the author's name which contains one or more spaces. For example, the url for the author "Ian Fleming" is: http://fadedpage.com/csearch.php?author=Fleming, Ian. My template call structure is {{FadedPage|id=Fleming, Ian|name=Ian Fleming|author=yes}}.
For my template I am replicating an existing template which uses a script coded in lua to parse the template arguments. I have been able to generate all of the url except for the space character between the last and first name.
I could code the template call as: {{FadedPage|id=Fleming,%20Ian|name=Ian Fleming|author=yes}} which works OK but I would rather have the call format as it looks on the fadedpage website, ie. with the embedded space. So I need a way in lua to find the space character within the string and substitute it for the string "%20". So far I haven't figured out how to do it. Any help would be appreciated.
I need to translate a website to a couple languages, and I've already read how to do it:
Mark strings for translation
Generate messages file
Translate messages file
The problem is, if I use whole sentences as the message ids, in english, for example, then if later I decide to modify the text, I'll have to change it in the code and on each message file . Or I could just change the english translation, but then my english message file will look weird, with translations from english to english which do not match.
Example:
Original: "I don't know what to do."
Translation: "I'm not sure what to do."
An alternative is to use unique message ids such as:
Original: "INDECISION_MESSAGE"
Translation: "I'm not sure what to do."
The advantage is that I can change translations without changing the id and things will still be consistent. But then there is no easy way for a translator to know what the message should be like as there is no context except by looking at the code.
What would you use?
In PHP people normally use the first approach you mentioned. In ASP.NET the second.
I think it's more of a personal taste and a matter of the framework that you use.
Personally I prefer the second option. Since you normally already have the ID/translation pair somewhere in a list, the translator can just take that list to translate.
What framework do you use?
i want to implement the following behaviour:
if the users browser-language is e.g. EN, he should be redirected to a the url http://foo.bar/hello, if the browser-language is DE then to http://foo.bar/hallo.
so how do i need to set my routes to redirect the user to the right language (e.g. when an english user requests the DE route and vice versa) and how can i set a hidden locale parameter, so i can load the right view in the controller?
i want to use the same controller for both languages (one method per page), but localized views (foo.en.html.erb etc.)
thanks in advance!
I don't think that what you want to try to get is a good idea, and I will explain that here. I don't understand why you would choose a different approach from the ones that are provided by Rails out of the box, and explained in details in the "Internationalization Guide, Sections 2.3 and further".
Here are the arguments:
Rails provides at least 3 different ways to change the locale:
Getting it from parameters: http://my.example.com/books?locale=de
Getting it from the sub-domain: http://de.example.com/books
Client supplied application, like the accept-header
All have the advantage that the controller and action will be the same, which is what you normally want to have.
There are helper methods if you want to change your behavior depending on the locate: locale, ...
However, you may localize views as a whole if you want to do: see localized views. This will perhaps lead to a duplication in view code.
Or you use the translation and localization API as in I18n.t 'store.title' or I18n.l Time.now.
A hidden locale parameter has the disadvantage that it is not obvious (for the user) which locale is used.
If you need to translate your routes in addition to set the locale, you may have a look to the translate_routes gem.
The README explains how you can set the locale from your translation hello/hallo.
I'm writing a restful XML API for a university assignment, the spec requires no HTML frontend.
There doesn't seem to be any documentation (or guessable functionality) regarding how to change the default format? Whilst thus far I have created all templates as ...Success.xml.php it would be easier to just use the regular ones and set this globally; I really expected this functionality to be configurable from YAML.. yet I have found some hard coded references to the HTML format.
The main issue I'm encountering is that part of the assessment is returning a 404 in a certain way (not as a 404 :/), but importantly it must always return XML, and the default setup of a missing route is a HTML 404 not XML (so it only works when I use forward404 from an action running via a XML route.
So in summary, is there a way to do this / what class(es) do I have to override?
Try putting this in factories.yml
all:
request:
class: sfWebRequest
param:
default_format: xml
That will still need the template names changing though. It will just mean that urls that don't specify a format will revert to xml instead of html.
You can subclass sfPHPView and override the initialise method to affect this (copy paste the initialise method from sfView) - the lines like this need changing:
if ('html' != $format)
You then need to change the view class used ... try this:
http://mirmodynamics.com/post/2009/02/23/symfony%3A-use-your-own-View-class
I've noticed that in my new Rails 3.0 application all German i18n strings are converted to lowercase (except for the first letter).
When having a string like this:
de:
email: "E-Mail"
the output is always like "E-mail". Same story with all the other strings - uppercase letters within a sentence are auto-converted to lowercase.
Is this default behaviour that I have to disable, or is there any other problem? I have successfully set the locale correctly, as these strings to actually work.
Thanks for your help
Arne
There should be no modifications to the content you specify as part of the internationalization process. It sounds like something is calling humanize on the string before it is output. Some of the standard Rails form helper methods do this I believe. If you just output the translation using t('email') you should see 'E-Mail' correctly.
Update:
From your comments it seems like it is a label that is causing the problem. If you explicitly specify the text for the label rather than relying on the default behaviour you will get the translation exactly as you specify. So,
<%= f.label(:email, t('email')) %>
should generate the correct label from the translations.
However, it isn't ideal. I think you may also run into problems with the generated validation error messages.
Got the same issue. solved it by adding the _html suffix to the I18n translation key. it seems that using this suffix suppresses the humanize usage.