I have a problem with changing the language in my portal. I use liferay 6.0.5, the default language is French in my portal, and there are some pages translated to English. I set the pages in portal_normal.vm as follows:
# set ($ pages_EN = ["/ services", "/ equipment"])
# if ($ language_id == 'en_GB')
# foreach ($ mypage pages_EN in $)
# if ($ == $ mypage layout.getFriendlyURL ())
# set ($ = $ rtlCssURL themeDisplay.getTheme (). getContextPath () + $themeDisplay.getTheme (). getCssPath () + "/ custom_en.css")
# css ($ rtlCssURL)
# end
# end
# end
I joined the portlet tongue on my portal_normal.vm to change language it works well.
What I want to do: When am in a EN page and I click on a page which has not translated to EN, I want to change the language (en -> fr) then redirect to the clicked link . Any ideas?
As there's no such thing as a "translated page" in Liferay, this is actually hard to answer in a way that will make sense: You might have translated "every article" on a page to a different language, but what will be the behaviour when you have 2 out of 3 articles translated?
The functionality I can imagine will be possible out-of-the-box in Liferay: Given the URLs http://example.com/home, http://example.com/fr/home and http://example.com/en/home, the last ones (with the language code) will show the requested language if that's available. The first URL will show the language that is available and best matches the user's requirement: Either through having stated that one is there preferred language (by being logged in and having set the default language in their profile) or by browser-content-negotiation (you can configure your preferred languages in your browser. This will be carried forward to the webserver)
Another option, that I doubt you speak about here, is that you're speaking about translated page titles, but they will also be covered by the behaviour I mentioned above.
If your scenario is different from that, please rephrase the question. As far as I can imagine what you ask for, I can't think of any requirement for redirects. The language will be chosen automatically based on availability and preferences.
Related
I am new to XWiki and not a Java Developer. I would like to develop a simple AppWithinMinutes app (Let us call it ServerCatalog) for a list of servers with their properties like OS, Environment, etc.. That is all doable. I can develop that from AppWithinMinites UI.
I also have developed a macro which lists all pages by tags.
Now for example, when Someone creates an entry in my ServerCatalog say SERVERD56 Where D stands for Development environment.
when we display that Entry, I also want to execute my macro that I developed so that it can list all pages that matches the tag SERVERX56.
Note that I replaced D with X So before executing macro, I want to manipulate that page title and remove Environment prefix (in this case D for Development Environment) with X.
I hope it is clear of what I want to accomplish. Please let me know if it is unclear.
If someone can assist me on doing it, I will truly appreciate that.
EDITS:
As suggested by Eduard Moraru, I tried following things:
I have created a custom macro called "PageListByTag".
Since python has more control over string operations, I added following at the end of ServerCatalogSheet
.
.
.
.
{{/html}}
{{/velocity}}
{{python}}
title = document.getTitle()
newTitle = title[:6] + "X" + title[6+1:]
print(newTitle)
{{/python}}
There are several problems with it..
my html tag is already ended. I can't inject any new content in it anymore
I can't add python code inside velocity tags as nested scripting is not allowed by XWiki
I still don't know how to call my macro inside python code if I want to use python
If I can replace 6th character in a string using velocity, then everything works. I can use macro inside velocity script since it is within that html boundaries.
As far as I understand, you want to customize the "sheet" of the application which is used when displaying an application entry.
If you have a look a the documentation's section on customization, you get a lot of starting points on where you should be looking:
https://extensions.xwiki.org/xwiki/bin/view/Extension/App%20Within%20Minutes%20Application#HCustomization
This line would be interesting (but also the above links on how XWiki applications work):
The sheet, which is used to display and edit application entries (e.g. HolidaySheet)
In your case, it the document to customize (edit in wiki syntax mode) should be ServerCatalog.Code.ServerCatalogSheet
Inside that document, you have code automatically generated by AWM to which you can add a call to your macro.
## AWM generated code...
...
## Customization:
{{displayAssociatedPages /}}
Then, inside this macro (called displayAssociatedPages, in this example), you could do something like:
{{velocity}}
#set ($title = $doc.title)
## OR #set ($title = $doc.name), depending if your pages have titles
#if ($title.startsWith('SERVERD'))
#set ($tag = $title.replaceFirst('SERVERD', 'SERVERX'))
##
## We can reuse and customize this snippet: https://snippets.xwiki.org/xwiki/bin/view/Extension/Display%20pages%20with%20a%20specific%20tag/
##
#set ($references = $xwiki.tag.getDocumentsWithTag($tag))
#foreach($reference in $references)
#set ($document = $xwiki.getDocument($reference))
#set ($label = $document.getTitle())
[[$label>>$reference]]
#end
#end
{{/velocity}}
API documentation and more info at https://www.xwiki.org/xwiki/bin/view/Documentation/DevGuide/API/
Also, you should understand that once you customize an AWM application, you should be careful when editing it with AWM itself. For example, if you add a new field, AFAIK, you risk having the customizations done to your sheet, as in the above example, overwritten, so you should recover them from document history and re-apply them.
I have two languages:
0: English, example.com (default language)
1: German, example.com/de/
If i visit the german version of the website i want all non-translated pages to appear in English, but with a link to the english page.
If i only set hidePagesIfNotTranslatedByDefault to false, pages don't appear.
If i additionally set fallbacks: '0' in the site config for the language German, pages titles appear in english, but with a link to a german version, e.g. example.com/de/my-page.
But this page doesn't exist and shouldn't exist (even not with content fallback), as that would mean duplicate content.
The goal is to show an all non-translated pages in their default language, with a correct link.
Is there a way to do it?
Updated: As I put in the comment under Brenden's response. I think the issue is not related to multilingual site, but it's with using Properties/ URLs / Path or Pattern feature. After adding value to the field Path of Pattern, the whole navigation stops working properly.
I have a multilingual site (English, French). Currently the URLs are like below:
English: www.domain.com/en-us/contact-us
French: www.domain.com/fr-fr/contact-us
What I want for French is a custom (translated) url www.domain.com/fr-fr/contactez-nous
I followed this Kentico instruction - the bottom part of the page with using Path or Pattern by adding /contactez-nous in the box. Things seem ok, but upon clicking on the page with the new URL on the French site, the whole main navigation (done with Hierarchical Viewer) seems to stuck with that URL; clicking anywhere on the nav doesn't do anything.
Links outside the nav works fine. How to make the nav work again. Thanks for your help!
I think I got it. The GetDocumentURL() is using NodeAliasPath to determine the URL. However, if you have not specified the NodeAliasPath column in the Columns property of the hierarchical viewer, then the current page's NodeAliasPath is used - and thus all items have the same URL. Adding the NodeAliasPath to the Columns property should fix the issue, so the hierarchical viewer has access to the data of each individual item.
EDIT: it looks like that in some cases the DocumentURLPath column must be specified too.
Make sure you're testing this in another browser or even another browser in a private window. If you are testing in a new tab in the same window, the CMS caches the selected language in the Kentico UI and shows that in the browser window.
For instance, if you have selected "French" on the pages app in the bottom left under the content tree, then navigate to your site in a new tab, it will display French no matter how many times you change the language selector on your public site to a new language.
Secondly, check the URL aliases for the given pages in each language. Make sure you don't have an alias that is the same in each language. For instance /contact-us with French and /contact-us in English.
I have a page I'd like to embed a news-feed widget into (so that the feed from some remote site will be displayed in my site).
While there are quite a few free news-feed widgets available out there (a partial list is here: http://allwebco-templates.com/support/S_script_newsfeed.htm), They all require insertion of complex code into the html page, while all the parameters are hard-coded into the generated code, which looks something like this:
insertedWidgetText = "<script id=\"scrnewsblock10795953\" type=\"text/javascript\">...script specific parameters go here...</script>"
let feedWidget = toWidgetBody [hamlet|#{preEscapedText insertedWidgetText}|]
This doesn't integrate well with Yesod's approach as it requires specifying to Hamlet that the content is preEscapedText, which in turn disables the ability to use Hamlet's processing to alter parameters of the widget dynamically (So in case I want the widget to use a different source, for example, I need to statically change the quoted text and cannot use Hamlet's variable substitution).
Of course I could do some text manipulation myself, tailor built for the widget I'm using, but that doesn't seem like the "right" solution (especially if I want to have the embedded text in some external file and not in the middle of my code as in the example above).
Can the above mentioned issue have a better solution than the one I thought about?
Is there an implementation of a news-feed widget in Haskell/Yesod that I can use as a plugin?
Note: I'm a very poor javascript programmer, but solutions in that direction are also welcomed.
Thanks,
enter code hereIn liferay there is a web content created that handle the Language issue , i didnt used it , i putted an img and want to link it to a language , with 2 images , for 2 langhuae Arabic and english, but what i dont know is the link to this content, as:
<a-href="????"><img srr="..."></a>
where can i get the url that attach me to the needed language...
regards
Well here is the solution we could found.
First of all, the common pattern for this behavior is that the download window was shown when a link was clicked (an anchor).
We changed our href addresses from something like "/web/guest/page-name" to something like "/en/web/guest/page-name" for english, and "/esp/web/guest/page-name" for Arabic.