I have a problem with language selector. Lets say I set English and Greek in dictionary item and default language is english. After changing the language to Greek, you could see pages displayed in greek but if you would click a subpage even though greek page is shown, the subpage you selected is displayed again in English.
Secondly if you would ever put the language selector in the page, the blank line is displayed under it. I also tried to validated my page against W3C Markup Validation Service, I get dozens of error related to language selector.
Regarding the first issue, the reason that this happens is that your links to the subpages probably do not have the language parameter appended to them. For example if you create a menu that lists all subpages of a page it is not enough to just list the urls, for example http://mysite.com/products/ . It needs to list them with the language parameter e.g. http://mysite.com/products/?lang=el
(or lang=en, etc depending on the language)
You can pick up the language code from the very same parameter that is added to the url automatically once you select a language from the drop down.
If you use the Translated Navigation macro (which is included in the package) to create your menu, this will already be done automatically for you. However it is most probable that you will want to create your own menus and submenus at some point. In that case I would suggest that you have a look at the source code of TranslatedNavigation (the corresponding xslt or cshtml script, depending on which version you use) and try to implement you menu or link generation code in the same way as far as the language parameter is concerned.
Regarding the errors produced by the Markup Validation Service, I have just ran a test myself and I see what you are saying. Thank you for bringing this to my attention. I am preparing a new version of the package to be released in a few days. The new version will list each language in its own language in the drop down (sorry for the recursion :)) for example "english", "français", etc. So I will try to correct the structure of the drop down as well, so that it gets successfully validated by w3c.
The new version I have mentioned above has just been released and is available for download. I have run the markup validation on it and it seems to be ok.
I will upload the new version but before doing it, should I delete all related TranslationFolders I created on nodes first? If yes, Uninstall old version and install new version?
Secondly, I placed second Translated Navigation on sub-nodes and it works properly now:) Lucky me. But I have something hard-coded in the the following. Dictionary items works properly until you click a link and it is displayed again default language but I do not know How I can add translated navigation feature to this hard-coded code snippet.
Thirdly I have a xslt code snippet which displays subnodes from a node but due to lack knowledge of xslt, I have no idea how to give again translated feature to that.
When upgrading the package you do not need to delete your translations or any of your work. Unless you have modified the files installed by the package itself (in which case you should keep track of your changes to apply them to the new version), whenever you upgrade, all you need to do is uninstall the old Polyglot package version and then install the new one. I would also suggest logging out and back into Umbraco after doing so, but that's all.
About the second question, instead of writing for each link <a href="/iletiim.aspx"><umbraco:Item field="#Contact us" runat="server"></umbraco:Item> directly into the template, I would suggest that you create your own macro, that takes the url and dictionary item name parameters, appends the language parameter to the url and outputs the a href link. The xslt would look like this:
Finally, about the third question, you need to do the following: In your xslt script, right above the <xsl:param name="currentPage"/> tag, enter <xsl:include href="../xslt/LanguageParameter.xslt" /> Replace <a href="{umbraco.library:NiceUrl(@id)}" > with <a href="{concat(umbraco.library:NiceUrl(@id), ‘?lang=’, $langISO)}" >
You would then need to get the translated texts for writerName and writerCaption or fall back to the corresponding values of the basic page. You can check the xslt for the Translated Navigation macro to see how this is done. For example this is the script for translating the title of each page:
<xsl:variable name="title"> <xsl:choose> <xsl:when test="child::*[name() = concat($currentPageTypeAlias, '_TranslationFolder')]/*[name() = concat($currentPageTypeAlias, '_Translation') and language = $langISO]/* [name() = $TitlePropertyAlias and not(@isDoc)] != '' and string-length(child::*[name() = concat($currentPageTypeAlias, '_TranslationFolder')]/*[name() = concat($currentPageTypeAlias, '_Translation') and language = $langISO]/* [name() = $TitlePropertyAlias and not(@isDoc)]) != 0"> <xsl:value-of disable-output-escaping="yes" select="child::*[name() = concat($currentPageTypeAlias, '_TranslationFolder')]/*[name() = concat($currentPageTypeAlias, '_Translation') and language = $langISO]/* [name() = $TitlePropertyAlias and not(@isDoc)]" /> </xsl:when> <xsl:otherwise> <xsl:choose> <xsl:when test="string-length(child::*[name() = concat($TitlePropertyAlias, '_', $langISO) and not(@isDoc)]) = 0"> <xsl:value-of disable-output-escaping="yes" select="child::* [name() = $TitlePropertyAlias and not(@isDoc)]" /> </xsl:when> <xsl:otherwise> <xsl:value-of disable-output-escaping="yes" select="child::*[name() = concat($TitlePropertyAlias, '_', $langISO) and not(@isDoc)]" /> </xsl:otherwise> </xsl:choose> </xsl:otherwise> </xsl:choose> </xsl:variable>
I know that this might seem to be a bit too much if you are not very familiar with xslt but trying to practice writing xslt a bit really helps when developing in Umbraco. Also, if you don't like xslt (some people don't :)) and are using Umbraco 4.7 you might want to consider switching to Razor. There is also a Razor version of the Polyglot package available for download at http://polyglot.codeplex.com . I find Razor a lot easier to work with.
Actually ds, about your third question I am preparing a function that will greatly simplify placing translated fields in your macros. I will make it available in a couple of days.
I installed the version of Polyglot_1.12.zip as recommended download on codeplex and whole structure and website displays properly but your suggestion to my second and third questions, there is not any LanguageParameter.xslt file in that package. Moreover PolyglotXslt_1.12.zip has that file. If I would use it, the translated menu is mixed totaly. Which one I should use it?
Since you are working with xslt scripts, PolyglotXslt_1.12.zip was the package to use. Polyglot_1.12.zip does not contain LanguageParameter.xslt but LanguageParameter.cshtml, because Polyglot_1.12.zip is the razor version of the package. cshtml scripts are razor scripts and they can be used by other razor scripts but not by xslt scripts.
In any case I have some good news :) I had more free time in my hands today than I thought so I have released yet another version of the package. So, don't download PolyglotXslt_1.12.zip, but PolyglotXslt_1.2.zip.
In order to change or upgrade the Polyglot package, you always just need to uninstall the existing version which you have and install the new one.
Version 1.2 contains a new script, PropertyReferenceTranslation.xslt , which greatly simplifies the answer to your third question. So, you can try to resolve the second question the way I have descibed, but for the third one there is much less code involved.
So about the third question just ignore what I said before and please try the following:
In your xslt script, right above the <xsl:param name="currentPage"/> tag, enter:
I have followed your suggestion but I have some problems and questions.
1) After installing version PolyglotXslt_1.2.zip, my whole level 1 nodes are displayed in Translated Navigation. With the razor version, the link worked as expected. Because I have not changed anything except uninstalling old version and install that latest version. What might cause it?
2) Regarding my second question the code snippet you supplied does not give me expected output
1) I am not sure I understand the problem. Could you tell me for example exactly what sort of items the xslt version displays and what items were being displayed when you were using the razor version?
2) Could you write to me an example of what is the output you expect and what is the output that is actually displayed? Do you pass the url and the dictionary item alias as parameters to the macro? Please note that, if you haven't already done so, you need to declare 2 parameters on the macro that corresponds to the xslt you create, one called "url" and the other one called "dictionaryItem" and pass the appropriate values there when you call the macro
3) Actually no. PropertyReferenceTranslation is the script you need to use here. PropertyTranslation works in connection to macros in templates. PropertyReferenceTranslation contains the template you will be calling when you write for example
<xsl:call-template name="PropertyReferenceTranslation"> <xsl:with-param name="nodeId" select="@id" /> <xsl:with-param name="Property" select="'writerCaption'" /> <!-- Note the single quotes (') inside the double quotes(") --> <xsl:with-param name="langISO" select="$langISO" /> </xsl:call-template>
The warning you get is becaue you probably have included PropertyTranslation and not PropertyReferenceTranslation in your script. Please let me know if you believe that I am not understanding something.
About the first issue I have just discovered that there was a bug in TranslatedNavigation in v1.2. Could you try downloading and using PolyglotXslt_1.21.zip ?
About the first problem, probably the bug which I corrected is not related to the issue you are facing. I have tested the package on a site of my own and it seems to work fine, so I assume that we have a different setup. Could you please describe the problem in a bit more detail, maybe with an example or some information about how your nodes are structured?
I attached a view of my menu right now in the following. I checked over all the steps again and it seems me OK cause when I select another languages and sub-menus, the polyglot works smoothly.
Also my node structure in the following,
Also on my master template, I have such structure as you described in the documentation but other codes omitted for clarity
Is the problem that you use a "hide from navigation" property or something like that to hide some nodes from the menu but they still appear nevertheless?
If so, when you call the macro, could you use NaviHideProperty="umbracoNaviHide" instead of NaviHideProperty="" ?
If that resolves the issue, it is still a bug. I intended the package to assume umbracoNaviHide is the property unless something else is passed there, but you can use this method to circumvent the issue until I fix it.
I managed to make it work regarding my second and third questions. Lucky me again:) Does Polyglot works well with search function? cause I have noticed that it does not now.
Please see attached file, The search results page displays it but without meaningful node name and you can not reach the page as you are expected.
You can find information about the matter there. In order for the redirection to work (if you do not want to customise your search results, even though I think it's better) all the translation document types need to have their template set to the Translation template, which is installed together with the package. This is also useful for previewing translations, as is mentioned in the documentation. If the template had not been set when the translation nodes were created you will probably need to re-save them in order for this to work.
The same information applies when searching using Examine.
About the search results, in order to get the proper title, you could do the following for each found node:
- check the retrieved node's type
if it ends in _Translation retrieve the id of the parent of its parent and store somewhere the language property of the retrieved node (fr, en, etc)
if it ends in _TranslationFolder ignore it and don't output it
otherwise keep its id and assume that the language is your default language
get the url for the node with the id which you have found above
use PropertyReferenceTranslation to retrieve the title in the proper language (using the id and the language found above)
return the title, with a hyperlink pointing to [url you have found]?lang=[language code you have found]
I did it this way once and it worked quite well. This way there is no need for the redirection of the Translation template either, so user experience and search engine optimisation are improved.
I have to admit, I am not sure what CreateUserWizard is :) I don't see any dictionary items in there, so I am not sure how to help you. I'll take two wild guesses:
- If you have a problem with Umbraco dictionary items not displaying in the proper language please make sure that you call the "Set Page Culture" macro (installed by the Polyglot package) at the top of all of your templates (basically, most likely, at the top of your master template if you are using one).
- If this is a user control and you cannot get the dictionary item tags to work in it, how about something like:
<%= umbraco.library.GetDictionaryItem("Job Title Error") %>
This should give you a head start. You might still need to do certain things like for example excluding the TranslationFolder nodes from the search or filtering the results by selected language but unfortunately I don't have any code for that at the moment. TranslationFolder nodes have not appeared in any of my searches anyway. Usually I have noticed that search results match the language of the query so I have not done any filtering also because I needed a unified result set. Just the above would usually suffice.
I see... I don't have any code with me for that, but you can follow the same logic using the Umbraco API.
Unfortunately in that case you would also need to translate the titles in your own code. Maybe taking a look at the script PropertyTranslation.cshtml from the Razor version can give you some ideas as Razor is closer to C#.
Language Selector
Hi again Dimitri,
I have a problem with language selector. Lets say I set English and Greek in dictionary item and default language is english. After changing the language to Greek, you could see pages displayed in greek but if you would click a subpage even though greek page is shown, the subpage you selected is displayed again in English.
Secondly if you would ever put the language selector in the page, the blank line is displayed under it. I also tried to validated my page against W3C Markup Validation Service, I get dozens of error related to language selector.
Any help much appreciated
Hello ds!
Regarding the first issue, the reason that this happens is that your links to the subpages probably do not have the language parameter appended to them. For example if you create a menu that lists all subpages of a page it is not enough to just list the urls, for example http://mysite.com/products/ . It needs to list them with the language parameter e.g. http://mysite.com/products/?lang=el
(or lang=en, etc depending on the language)
You can pick up the language code from the very same parameter that is added to the url automatically once you select a language from the drop down.
If you use the Translated Navigation macro (which is included in the package) to create your menu, this will already be done automatically for you. However it is most probable that you will want to create your own menus and submenus at some point. In that case I would suggest that you have a look at the source code of TranslatedNavigation (the corresponding xslt or cshtml script, depending on which version you use) and try to implement you menu or link generation code in the same way as far as the language parameter is concerned.
Regarding the errors produced by the Markup Validation Service, I have just ran a test myself and I see what you are saying. Thank you for bringing this to my attention. I am preparing a new version of the package to be released in a few days. The new version will list each language in its own language in the drop down (sorry for the recursion :)) for example "english", "français", etc. So I will try to correct the structure of the drop down as well, so that it gets successfully validated by w3c.
Cheers
Dimitri
Hi!
The new version I have mentioned above has just been released and is available for download. I have run the markup validation on it and it seems to be ok.
Hi Dimitri!,
I will upload the new version but before doing it, should I delete all related TranslationFolders I created on nodes first? If yes, Uninstall old version and install new version?
Secondly, I placed second Translated Navigation on sub-nodes and it works properly now:) Lucky me. But I have something hard-coded in the the following. Dictionary items works properly until you click a link and it is displayed again default language but I do not know How I can add translated navigation feature to this hard-coded code snippet.
Thirdly I have a xslt code snippet which displays subnodes from a node but due to lack knowledge of xslt, I have no idea how to give again translated feature to that.
Hi ds!
When upgrading the package you do not need to delete your translations or any of your work. Unless you have modified the files installed by the package itself (in which case you should keep track of your changes to apply them to the new version), whenever you upgrade, all you need to do is uninstall the old Polyglot package version and then install the new one. I would also suggest logging out and back into Umbraco after doing so, but that's all.
About the second question, instead of writing for each link <a href="/iletiim.aspx"><umbraco:Item field="#Contact us" runat="server"></umbraco:Item> directly into the template, I would suggest that you create your own macro, that takes the url and dictionary item name parameters, appends the language parameter to the url and outputs the a href link. The xslt would look like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp " "> ]>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxml="urn:schemas-microsoft-com:xslt"
xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" xmlns:dimi.polyglot="urn:dimi.polyglot"
exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets dimi.polyglot ">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:include href="../xslt/LanguageParameter.xslt" />
<xsl:param name="currentPage"/>
<xsl:template match="/">
<xsl:param name="url" select="macro/url" />
<xsl:param name="dictionaryItem" select="macro/dictionaryItem" />
<a href="{concat($url, '?lang=', $langISO)}"><xsl:value-of select="umbraco.library:GetDictionaryItem($dictionaryItem)"/></a>
</xsl:template>
</xsl:stylesheet>
Finally, about the third question, you need to do the following:
In your xslt script, right above the <xsl:param name="currentPage"/> tag, enter <xsl:include href="../xslt/LanguageParameter.xslt" />
Replace <a href="{umbraco.library:NiceUrl(@id)}" > with <a href="{concat(umbraco.library:NiceUrl(@id), ‘?lang=’, $langISO)}" >
You would then need to get the translated texts for writerName and writerCaption or fall back to the corresponding values of the basic page. You can check the xslt for the Translated Navigation macro to see how this is done. For example this is the script for translating the title of each page:
<xsl:variable name="title">
<xsl:choose>
<xsl:when
test="child::*[name() = concat($currentPageTypeAlias, '_TranslationFolder')]/*[name() = concat($currentPageTypeAlias, '_Translation') and language = $langISO]/* [name() = $TitlePropertyAlias and not(@isDoc)] != '' and
string-length(child::*[name() = concat($currentPageTypeAlias, '_TranslationFolder')]/*[name() = concat($currentPageTypeAlias, '_Translation') and language = $langISO]/* [name() = $TitlePropertyAlias and not(@isDoc)]) != 0">
<xsl:value-of disable-output-escaping="yes"
select="child::*[name() = concat($currentPageTypeAlias, '_TranslationFolder')]/*[name() = concat($currentPageTypeAlias, '_Translation') and language = $langISO]/* [name() = $TitlePropertyAlias and not(@isDoc)]" />
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="string-length(child::*[name() = concat($TitlePropertyAlias, '_', $langISO) and not(@isDoc)]) = 0">
<xsl:value-of disable-output-escaping="yes" select="child::* [name() = $TitlePropertyAlias and not(@isDoc)]" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of disable-output-escaping="yes"
select="child::*[name() = concat($TitlePropertyAlias, '_', $langISO) and not(@isDoc)]" />
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
I know that this might seem to be a bit too much if you are not very familiar with xslt but trying to practice writing xslt a bit really helps when developing in Umbraco. Also, if you don't like xslt (some people don't :)) and are using Umbraco 4.7 you might want to consider switching to Razor. There is also a Razor version of the Polyglot package available for download at http://polyglot.codeplex.com . I find Razor a lot easier to work with.
Regards,
Dimitri
Actually ds, about your third question I am preparing a function that will greatly simplify placing translated fields in your macros. I will make it available in a couple of days.
Hi Dimitri,
I have just had a chance to check my posts. I will try your suggestion and let you know about the results.
Dimitri,
I installed the version of Polyglot_1.12.zip as recommended download on codeplex and whole structure and website displays properly but your suggestion to my second and third questions, there is not any LanguageParameter.xslt file in that package. Moreover PolyglotXslt_1.12.zip has that file. If I would use it, the translated menu is mixed totaly. Which one I should use it?
Hello ds!
Since you are working with xslt scripts, PolyglotXslt_1.12.zip was the package to use. Polyglot_1.12.zip does not contain LanguageParameter.xslt but LanguageParameter.cshtml, because Polyglot_1.12.zip is the razor version of the package. cshtml scripts are razor scripts and they can be used by other razor scripts but not by xslt scripts.
In any case I have some good news :) I had more free time in my hands today than I thought so I have released yet another version of the package. So, don't download PolyglotXslt_1.12.zip, but PolyglotXslt_1.2.zip.
In order to change or upgrade the Polyglot package, you always just need to uninstall the existing version which you have and install the new one.
Version 1.2 contains a new script, PropertyReferenceTranslation.xslt , which greatly simplifies the answer to your third question. So, you can try to resolve the second question the way I have descibed, but for the third one there is much less code involved.
So about the third question just ignore what I said before and please try the following:
In your xslt script, right above the <xsl:param name="currentPage"/> tag, enter:
<xsl:include href="../xslt/LanguageParameter.xslt" />
<xsl:include href="../xslt/PropertyReferenceTranslation.xslt" />
Replace <a href="{umbraco.library:NiceUrl(@id)}" > with <a href="{concat(umbraco.library:NiceUrl(@id), ‘?lang=’, $langISO)}" >
Replace <xsl:value-of select="writerCaption"/> with the following:
<xsl:call-template name="PropertyReferenceTranslation">
<xsl:with-param name="nodeId" select="@id" />
<xsl:with-param name="Property" select="'writerCaption'" /> <!-- Note the single quotes (') inside the double quotes(") -->
<xsl:with-param name="langISO" select="$langISO" />
</xsl:call-template>
Replace <xsl:value-of select="writerName"/> with the following:
<xsl:call-template name="PropertyReferenceTranslation">
<xsl:with-param name="nodeId" select="@id" />
<xsl:with-param name="Property" select="'writerName'" /> <!-- Note the single quotes (') inside the double quotes(") -->
<xsl:with-param name="langISO" select="$langISO" />
</xsl:call-template>
I hope that this helps!
By the way, many thanks for all your feedback. You have really helped me improve the package! :)
Regards,
Dimitri
Hi Dimitri,
I have followed your suggestion but I have some problems and questions.
1) After installing version PolyglotXslt_1.2.zip, my whole level 1 nodes are displayed in Translated Navigation. With the razor version, the link worked as expected. Because I have not changed anything except uninstalling old version and install that latest version. What might cause it?
2) Regarding my second question the code snippet you supplied does not give me expected output
I have been still trying to get expected result but till then I need your guidance litte bit further.
3) Regarding my third question, the file you mention should be PropertyTranslation instead of PropertyReferenceTranslation.
Also after adding
<xsl:include href="../xslt/LanguageParameter.xslt" />
<xsl:include href="../xslt/PropertyReferenceTranslation.xslt" /> right above <xsl:param name="currentPage"/>
I get the warning of The variable or parameter 'currentPage' was duplicated with the same import precedence.
so I am stuck at all three stages, dimitri,
Hi ds,
Regarding the numbered questions:
1) I am not sure I understand the problem. Could you tell me for example exactly what sort of items the xslt version displays and what items were being displayed when you were using the razor version?
2) Could you write to me an example of what is the output you expect and what is the output that is actually displayed? Do you pass the url and the dictionary item alias as parameters to the macro? Please note that, if you haven't already done so, you need to declare 2 parameters on the macro that corresponds to the xslt you create, one called "url" and the other one called "dictionaryItem" and pass the appropriate values there when you call the macro
3) Actually no. PropertyReferenceTranslation is the script you need to use here. PropertyTranslation works in connection to macros in templates. PropertyReferenceTranslation contains the template you will be calling when you write for example
<xsl:call-template name="PropertyReferenceTranslation">
<xsl:with-param name="nodeId" select="@id" />
<xsl:with-param name="Property" select="'writerCaption'" /> <!-- Note the single quotes (') inside the double quotes(") -->
<xsl:with-param name="langISO" select="$langISO" />
</xsl:call-template>
The warning you get is becaue you probably have included PropertyTranslation and not PropertyReferenceTranslation in your script. Please let me know if you believe that I am not understanding something.
Regards,
Dimitri
ds,
About the first issue I have just discovered that there was a bug in TranslatedNavigation in v1.2. Could you try downloading and using PolyglotXslt_1.21.zip ?
Sorry about that.
Regards,
Dimitri
Dimitri,
Still the same bug continuous but I have not had a chance to check second and third questions. I will let you know as well
ds,
About the first problem, probably the bug which I corrected is not related to the issue you are facing. I have tested the package on a site of my own and it seems to work fine, so I assume that we have a different setup. Could you please describe the problem in a bit more detail, maybe with an example or some information about how your nodes are structured?
Regards,
Dimitri
Dimitri,
I attached a view of my menu right now in the following. I checked over all the steps again and it seems me OK cause when I select another languages and sub-menus, the polyglot works smoothly.
Also my node structure in the following,
Also on my master template, I have such structure as you described in the documentation but other codes omitted for clarity
As I said after sorting this problem out, I will check your answers my second and third questions
ds,
Is the problem that you use a "hide from navigation" property or something like that to hide some nodes from the menu but they still appear nevertheless?
If so, when you call the macro, could you use NaviHideProperty="umbracoNaviHide" instead of NaviHideProperty="" ?
If that resolves the issue, it is still a bug. I intended the package to assume umbracoNaviHide is the property unless something else is passed there, but you can use this method to circumvent the issue until I fix it.
Regards,
Dimitri
Dimitri,
It is exactly a bug. I knew that default NaviHideProperty is umbracoNaviHide so I left it blank but following works now
now it is time to check my other problems. I will let you know about my other questions.
Thanks for the feedback so far
You're welcome ds!
In the meantime, I have released version 1.22 of the package, which fixes the umbracoNaviHide issue.
Regards,
Dimitri
Dimitri,
I managed to make it work regarding my second and third questions. Lucky me again:) Does Polyglot works well with search function? cause I have noticed that it does not now.
Please see attached file, The search results page displays it but without meaningful node name and you can not reach the page as you are expected.
Sorry this is a duplicate post, admin might delete this one
ds,
This is a discussion about using the package with xslt search:
http://our.umbraco.org/projects/backoffice-extensions/polyglot/polyglot-package-feedback,-bug-reports,-assistance,-etc/22683-Xslt-search
You can find information about the matter there. In order for the redirection to work (if you do not want to customise your search results, even though I think it's better) all the translation document types need to have their template set to the Translation template, which is installed together with the package. This is also useful for previewing translations, as is mentioned in the documentation. If the template had not been set when the translation nodes were created you will probably need to re-save them in order for this to work.
The same information applies when searching using Examine.
Best regards,
Dimitri
Dimitri,
I would try to customise the search result, The only disadvantage I see that you get the output as "en" or "gr" as you have already seen above.
Besides it, I try to set dictionary items for Validation Controls like RequiredFieldValidator, RegularExpressionValidator on page Load
I managed to do like in the following
But with CreateUserWizard, I could not manage to work it
Is there another way to set dictionary item at createuserwizard?
Hello ds!
About the search results, in order to get the proper title, you could do the following for each found node:
- check the retrieved node's type
if it ends in _Translation retrieve the id of the parent of its parent and store somewhere the language property of the retrieved node (fr, en, etc)
if it ends in _TranslationFolder ignore it and don't output it
otherwise keep its id and assume that the language is your default language
get the url for the node with the id which you have found above
use PropertyReferenceTranslation to retrieve the title in the proper language (using the id and the language found above)
return the title, with a hyperlink pointing to [url you have found]?lang=[language code you have found]
I did it this way once and it worked quite well. This way there is no need for the redirection of the Translation template either, so user experience and search engine optimisation are improved.
I have to admit, I am not sure what CreateUserWizard is :) I don't see any dictionary items in there, so I am not sure how to help you. I'll take two wild guesses:
- If you have a problem with Umbraco dictionary items not displaying in the proper language please make sure that you call the "Set Page Culture" macro (installed by the Polyglot package) at the top of all of your templates (basically, most likely, at the top of your master template if you are using one).
- If this is a user control and you cannot get the dictionary item tags to work in it, how about something like:
<%= umbraco.library.GetDictionaryItem("Job Title Error") %>
I'm not sure if this helps you, but I hope so.
Best regards,
Dimitri
Hi Dimitri,
Would you mind providing code samples for search function I could take advantage of?
I also sorted it out by doing like that for Validation controls.
Regards
Hello ds,
For example if you are using XSLTSearch version 3.0.3, in the script XSLTsearch.xslt you could do the following.
Add the following namespace at the top where the rest of the namespaces are declared in a similar manner:
Add the following line around line 35, right above the currentPage parameter declaration:
Around line 350 replace this:
with this (assuming that you call the title of each of your nodes 'title'):
This should give you a head start. You might still need to do certain things like for example excluding the TranslationFolder nodes from the search or filtering the results by selected language but unfortunately I don't have any code for that at the moment. TranslationFolder nodes have not appeared in any of my searches anyway. Usually I have noticed that search results match the language of the query so I have not done any filtering also because I needed a unified result set. Just the above would usually suffice.
Cheers,
Dimitri
I am using Lucene Examiner on my website but I would have a look at what you suggested, Dimitri.
I see... I don't have any code with me for that, but you can follow the same logic using the Umbraco API.
Unfortunately in that case you would also need to translate the titles in your own code. Maybe taking a look at the script PropertyTranslation.cshtml from the Razor version can give you some ideas as Razor is closer to C#.
Regards,
Dimitri
I have passed the hard part by using your packet and it works smoothly now. I would work on customizing search function little bit later.
Cool! Good to hear that things are going well!
Good luck with the rest of the work!
Cheers,
Dimitri
is working on a reply...