Orchardcore: Multi language web site

Created on 8 Dec 2019  路  40Comments  路  Source: OrchardCMS/OrchardCore

I need to add another language to my web site.

i read this help :
https://orchardcore.readthedocs.io/en/dev/docs/reference/modules/ContentLocalization/

i added this code, but it doesn't show my cultures:

<ul>
    <li class="nav-item dropdown">
        <a class="nav-link dropdown-toggle" href="#" id="oc-culture-picker" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">{{Model.CurrentCulture.DisplayName}}</a>
        <div class="dropdown-menu" aria-labelledby="oc-culture-picker">
        {% for culture in Model.SupportedCultures %}
            {% if culture.Name != Model.CurrentCulture.Name  %}
            <a class="dropdown-item" href="{{culture.Name | switch_culture_url }}">{{culture.DisplayName}}</a>
            {% endif %}
        {% endfor %}
        </div>
    </li>
</ul>

with this shape it shows the cultures :
{% shape "ContentCulturePicker" %}

if i change the culture it shows the content for that culture but after going to another page it with the change to default culture.

how can i fix the culture?

do you have better help to do a multi-language web site?

discussion

Most helpful comment

Cookie '.AspNetCore.Culture'

All 40 comments

You can find my implementation notes here https://github.com/OrchardCMS/OrchardCore/issues/4121. It contains a lot of info regarding website implementation including multi lingual implementation.

Further discussion about culture switching can be found here https://github.com/OrchardCMS/OrchardCore/issues/4594

@dodyg i followed the topics, but it doesn't work. i think it needs better documentation.

Thanks @dodyg for your reply, hope to add some of your notes to the docs if it's possible

@aghili371 what exactly doesn't work with you?

hope to add some of your notes to the docs if it's possible

Feel free to repackage anything I've written.

I mean hope you add some of your notes in the docs 馃槉

@aghili371 what exactly doesn't work with you?

i think it doesn't save the current language. after running in next time, it doesn't know the selected language.

Do you mean the current cultures picker?

Do you mean the current cultures picker?

yes that is true. so if i visit the web site and selected my language, why i should change the language in the next visit on other days? i think it needs to save the currently selected culture in user browser

why i should change the language in the next visit on other days?

The language is not saved, this the behavior common for almost websites if not all, what you said is suitable for admin language

i checked Microsoft website, they just using culture in URLs.
products.office.com/**en**/compare-all-microsoft-office-products?=&activetab=tab%3Aprimaryr2&market=af

Ya, this is a querstring which already supported, but I'm not sure if @jptissot is use it or he used Cookie instead

Cookie '.AspNetCore.Culture'

As expected

this is correct?
<body dir="{{Culture.Dir}}" >

it doesn't work for me:
<body dir="" data-gr-c-s-loaded="true">

How the culture fallback to invariant culture?!!

s

i selected invariant language, it is empty.

Why you do that?

i need to add de, fa-ir, ar too.

Why you didn't add them directly to the supported cultures list?

The Invariant culture name is String.Empty(). That's a small display issue.

The Invariant culture name is String.Empty()

Ya, but still wondering why he added it, while the intend is support de, ar and fa-IR cultures

I think that on Mac OS or some Linux distributions if it doesn't find a proper InstalledUICulture it will install the fallback culture "on setup" which is the Invariant one. That's probably why he has it. And remember that a culture cannot be NULL ever.

Be careful as an empty dir attribute on the html element is Invalid html

The Invariant culture name is String.Empty()

Ya, but still wondering why he added it, while the intend is support de, ar and fa-IR cultures

i just wanted to show you that. i have en and de.

the problem in getting empty dir by {{Culture.Dir}}

the problem in getting empty dir by {{Culture.Dir}}

Try to print out the CultureInfo.CurrentUICulture

Do we have the ability to localize site settings for every culture? for example, the site name is there, so it is not correct to use same name for all cultures.

AFAIK everything should be localized except the once that data related, there's already a draft PR for data localization support

It would be super useful to have the ability to add custom key value pairs for simple localized strings.
Then be able to refer them like site settings but it would get a localized version based on the current culture:

{{Site.LocalizedStrings.SomeKey}}

or

{{Site.LocalizedStrings['fr'].SomeKey}}

CultureInfo.CurrentUICulture

i used this:
<body dir="{{CultureInfo.CurrentUICulture}}" >
it still empty

This will not happen unless you are using InvariantCulture!!

{{ CultureInfo.CurrentUICulture }} won't work. You need to debug and see what {{Culture.Dir}} returns and why. And for returning the current CultureInfo you need to use {{ Culture }} simply.

See CultureLiquidTemplateEventHandler.cs

I didn't realize that we have the same bug that we faced in Razor, @aghili371 you could use the latest bits and the lang will be rtl

Is there any further questions?

how can i use .po in jquery?
i need to show messages in multi culture :
$("#msg" + type).html("Please add your Email*");

I suggest to file a new issue, coz the original issue was about multilingual websites, but I notice it moves to another direction

I suggest to file a new issue, coz the original issue was about multilingual websites, but I notice it moves to another direction

okey i will file a new issue

Is there any further thing here, or shall I close this?

Is there any further thing here, or shall I close this?

i just do a multilingual website and report the problems here, but if you think it will better to file new for any problem, close this.

I will close this for now, bu t feel free to create new issues if you find any problems or bugs

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jeffolmstead picture jeffolmstead  路  4Comments

cbadger360 picture cbadger360  路  4Comments

ns8482e picture ns8482e  路  4Comments

deanmarcussen picture deanmarcussen  路  3Comments

chillibug picture chillibug  路  4Comments