You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -301,30 +300,30 @@ public class ExampleController : SurfaceController
301
300
}
302
301
```
303
302
304
-
##Creating a Language Switching Navigation
303
+
### Creating a Language Switching Navigation
305
304
306
-
To navigate between languages, we need to do two key things:
305
+
To navigate between languages, you need to do two key things:
307
306
308
307
1. Get all the languages that the site can provide
309
308
2. Identify the language used on the current page
310
309
311
-
Once we have these, we need to loop through the languages, and provide links to each home node.
310
+
Once you have these, you need to loop through the languages and provide links to each home node.
312
311
313
-
#Getting all the languages for a site
312
+
### Getting all the languages for a site
314
313
315
-
There are three ways to achive this. The best one is to use ```languageService.GetAllAsync();``` which retrives items from the cache.
314
+
There are three ways to achieve this. The best one is to use `languageService.GetAllAsync();` which retrieves items from the cache.
316
315
317
-
Another is to use ```localizationService.GetAllLanguages();``` to call the database, which is expensive and ideally includes caching. This should only be done if you cannot use the ILanguage service. This service is marked as obsolete.
316
+
Another is to use `localizationService.GetAllLanguages();` to call the database, which is expensive and ideally includes caching. This should only be done if you cannot use the ILanguage service. This service is marked as obsolete.
318
317
319
-
The alternative is to get the Home node, and find all of the cultures associated to it. This has a few benifits including speed and providing us with a link to show the user. It is the process we will use.
318
+
The alternative is to get the Home node and find all of the cultures associated with it. This has a few benefits including speed and providing us with a link to show the user. It is the process you will use when following this guide.
320
319
321
-
#Identify the language for the current page
320
+
### Identify the language for the current page
322
321
323
-
This is achived in ```cs.html``` files using ```umbracoHelper.AssignedContentItem.GetCultureFromDomains();```
322
+
This is achieved in `cs.html` files using `umbracoHelper.AssignedContentItem.GetCultureFromDomains();`
324
323
325
-
#Steps
324
+
#### Steps
326
325
327
-
Now we have what we need, create a view called ```Navigation.cshtml```, and paste in the following:
326
+
Now that you have what you need, create a view called `Navigation.cshtml`, and paste in the following:
328
327
329
328
```cshtml
330
329
@using Umbraco.Cms.Web.Common
@@ -344,7 +343,7 @@ Now we have what we need, create a view called ```Navigation.cshtml``` , and pas
344
343
{
345
344
//get the settings for this culture
346
345
System.Globalization.CultureInfo culture = new System.Globalization.CultureInfo(cult.Key);
347
-
//if the current page has a langauage variant, otherwise link to the homepage language variant
346
+
//if the current page has a language variant, otherwise link to the homepage language variant
@@ -362,7 +361,8 @@ Now we have what we need, create a view called ```Navigation.cshtml``` , and pas
362
361
}
363
362
```
364
363
365
-
You will need to replace ```{{homeNodeContentAlias}}``` with the Document Type alias of your Home node.
364
+
You need to replace `{{homeNodeContentAlias}}` with the Document Type alias of your Home node.
365
+
366
+
This will look at all the cultures available on the home node, and render links to either the language variant of the current page or the home node for the language variant. If the home node for a language variant is removed, it will not appear in the list.
366
367
367
-
This will look at all the cultures available on the home node, and render links to either the language variant of the current page, or the home node for the language variant. If the home node for a language variant is removed, it will not appear in the list.
368
-
Additionally, ```System.Globalization.CultureInfo``` is used to obtain the native name of the language being rendered. This is useful if a user does not speak the default language of the site.
368
+
Additionally, `System.Globalization.CultureInfo` is used to obtain the native name of the language being rendered. This is useful if a user does not speak the default language.
0 commit comments