Create new language in mid-project - sitecore

Was requested by the client a new language to add to the project in sitecore. I'm having some issues with that,
I've created the language, however all the renderings are empty for the new language.
There's no version assigned to any item for the new language also.
I tried to do a trick that was to export the English language and open the generated xml file and rename the tags , to the requested language and then import. But when I'm trying to import it, shows as I was importing English language and not the new one.
How can I create a new language with all the renderings and content (even if it goes to english when empty string, I know it's default procedure) ?
Thanks

You can use Powershell script for that.
See e.g. this blog http://www.coreblimeysitecore.com/blog/create-language-versions-using-sitecore-powershell/
Sample code is
Add-ItemLanguage -Path "master:\sitecore\content" -Language "en" -TargetLanguage "de-AT","de-de","en-za","fi-fi","fr-be","it-it","pl-pl","ru-ru","sv-se","fr-fr" -IfExist OverwriteLatest -IgnoredFields ""
And here is a very similar question on http://sitecore.stackexchange.com site:
https://sitecore.stackexchange.com/questions/1584/create-new-language-version-for-content-branch

Related

Can not add new languages in OpenCart 2.2.0.0. The "code" dropdown only has "en-gb" value

I am trying to localize a new OpenCart website. I've download the language in question and extracted it under /catalog/language/[xx] (the two letter lang code of the custom language).
However, when I go to Gear menu->Localization->Languages and click "Add new":
The "Code" dropdown only has the "en-gb" value:
Adding another language with the same "Code" is impossible, because it generates an error.
Apparently, instead of unzipping everything from the language pack archive under category/language/[xx] I had to unzip the individual directories from the language pack under:
/admin/language/[xx]/
/catalog/language/[xx]/
/install/language/[xx]/
The lang pack's .zip file was neatly organized in this subfolder structure, but I overlooked this fact. I hope this is useful information for future searchers.

Extract a portion of a docx into a new docx

I have a docx file with just text. I would like to create a new docx file containing just part of a page in the original docx. I am using python-docx for this.
So far I have been able to transverse the original docx document and copy each desired paragraph/run in the original to the new document as follows (this example should make an exact copy, I believe):
Doc = docx.Document('/tmp/input.docx')
OutDoc = docx.Document()
for para in Doc.paragraphs:
currentParagraph = OutDoc.add_paragraph(style=para.style)
for run in para.runs:
currentParagraph.add_run(run.text, style=run.style)
OutDoc.save('/tmp/output.docx')
Even though I am copying all style information, it seems that I am missing something, as the output lacks some of the formatting.
In Word, the style name applied to a paragraph or run (or any other content) is ignored if that style is not explicitly defined in the new document.
You can either parse through the styles in the source document and recreate each one in the new document, or create a blank "template" document for the new document that already contains the styles you want.
The "default" python-docx document template includes many of the built-in styles, but if your document uses any customized styles, that would explain the symptom you're seeing.
See these pages in the documentation for more:
http://python-docx.readthedocs.org/en/latest/user/styles-understanding.html
http://python-docx.readthedocs.org/en/latest/user/styles-using.html
http://python-docx.readthedocs.org/en/latest/api/document.html#docx.document.Document.styles
http://python-docx.readthedocs.org/en/latest/api/style.html

How to disable Sitecore's embedded language parser

I have a site that has many URL rewrites and a good portion of them contain old links that are prefixed with a country code (e.g. /fr, /de, etc). Rewrites without the prefixes work just fine but those with trigger Sitecore's embedded language URL parser which bypasses the rewrite module entirely.
Example
/fr/old-link tries to parse 'fr' as a language and fails as 'fr-FR' is the name of the French language.
Solution I need to disable Sitecore's ability to detect a language prefix in the URL so the URL rewrite module can proceed unhindered.
I can't find where it is in the pipeline that this occurs. I've gone through numerous with Reflector and come up short. I need help please.
Another pipeline to look at is the preprocessRequest pipeline. It has a StripLanguage processor that detects if the first part of the URL is a language and acts on it.
More info on how to get Sitecore to ignore the language part of the url can be found in this post http://sitecoreblog.patelyogesh.in/2013/11/sitecore-item-with-language-name.html
You will need to create a new LanguageResolver to replace the standard Sitecore one (Sitecore.Pipelines.HttpRequest.LanguageResolver). This is referenced in the <httpRequestBegin> pipeline section in web.config. Here you can handle requests beginning with fr as opposed to fr-FR etc. In the past I have done a similar thing for when we wanted to use non-ISO language codes.
EDIT
The LanguageResolver resolves language based on query string first, but will also resolve based on file path (i.e. having fr-FR in the start of your path). I think you would need to inherit from the Sitecore LanguageResolver and override the GetLanguageFromRequest method changing the else statement to use something different to Context.Data.FilePathLanguage - possibly just using regex/string manipulation to get the first folder from the URL then use that to set the context language. This should prevent the failure to resolve language which I understand is killing your URL rewrite module.

Sitecore Import language file feature - does it create language versions?

Can anyone tell me what happens if I export a language file, rename all the language nodes to a different language (e.g. from en-US to en-GB) and then import it?
Are new language versions of the relevant items created? Or is content only imported if the language version exists?
Edit: corrected typo in title
Yes, the new language versions are created. However, the language item itself is not created (if it doesn't exist before). Hence, if you run a Database Clenup afterwards, for instance, it will remove these item versions.

How to get multiple language sites set up in Sitecore?

I am just starting to add support for multiple languages on my site... having a spot of trouble. Here are the steps I've taken so far:
In Control Panel -> Globalization, added a new language (German)
Added a new <site> definition in Web.config with hostName="localGerman.com" and language="de". Also added an alias in my hosts file for localgerman.com to point to localhost and added the host header in IIS.
Went to an item in my tree and added a new version for German. Published whole site.
Now, the host/site setup seems to work OK. When to go to http://localgerman.com/ I get my home page, with lots of missing data... there is no German version... so seems to be using the correct language.
However... when I go to the item I've added a German version of, I still get blank data. In the debugger, I can see that Sitecore.Context.Item is the German version... but all the fields are blank. Item["Content"] returns an empty string. If I manually set the language to "en" on the URL (http://localgerman.com/myitem.aspx?sc_lang=en), then I get the English version with data.
What am I missing here?
Also... when loading the German home page... my menu is blank. Presumably because the items which generate this content do not have German versions. I was under the assumption that when a language-specific version for a given item could not be loaded, then the default language version is used? But this does not seem to be the case. Am I wrong?
OK, looks like I just had the language code wrong. Setting the site language to "de-DE" instead of just "de" worked.
This is a little confusing because the default sites use language="en" instead of en-US.
You added a German version of an item, but did you fill in the fields in German ? Any localizable fields (non-shared) will be empty by default when a new version is created. It sounds like you did the other parts correctly.
The menu being blank is expected: When you try to get an language version of an item that doesn't exist, Sitecore will return null.