-
Notifications
You must be signed in to change notification settings - Fork 775
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update adding-language-variants.md #6360
base: main
Are you sure you want to change the base?
Conversation
Added some support for setting cultures in API calls
Thanks for the PR, @jonathoncove2 🙌 We will review it as soon as we can. 💪 |
Thanks for the PR @jonathoncove2 ! 💪 The "Creating a basic site" tutorial is meant to be very high-level and shouldn't dive into more code than the cshtml and CSS files. |
Thanks for looking over this @sofietoft ! I agree that page is a more suitable place for this code. Would you prefer me to make a new PR for this? I also considered some example code showing how to add a language switching menu, would that be a useful addition? |
Excellent! It would be amazing with a language switcher 👏 The "Create a multilingual site" tutorial is a bit long and messy at the moment. |
Added a guide for creating a basic language switching navigation
I've removed that API example as requested and added a language switcher. Not sure if my link from adding-language-variants.md works correctly, that might need to be fixed. I've also added sub headers, hopefully to guide users googling the same things I was. I'm about to go on holiday for a week and half, but feel free to Umbraco-ify the PR and approve it while I'm away. |
Amazing @jonathoncove2 ! Have a wonderful holiday 🏖️ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jonathoncove2 I made some comments about the ILocalizationService, do you think you can rewrite the part but using the ILanguage service instead?
```csharp | ||
public class ExampleController : SurfaceController | ||
{ | ||
private readonly ILocalizationService _localizationService; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ILocalizationService is currently marked as obsolete and will be removed in v15. If we decide to keep this one, we have to include a note that the above is obsolete.
Preferably, make this example use the ILanguageService instead
|
||
public IActionResult Index(string culture = null) | ||
{ | ||
IEnumerable<ILanguage> UmbracoLanguages = _localizationService.GetAllLanguages(); //a helpful method to get all configured languages |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something like this could be used instead of calling the database:
https://apidocs.umbraco.com/v14/csharp/api/Umbraco.Cms.Core.Services.ILanguageService.html#Umbraco_Cms_Core_Services_ILanguageService_GetAllAsync
|
||
#Getting all the languages for a site | ||
|
||
There are two ways to achive this. One is to use ```localizationService.GetAllLanguages();``` to call the database, which is expensive and ideally includes caching. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could still keep this part, but instead it would be 3 ways to get the languages.
Then show of each with the not that the localizationService very expensive to do and should only be done if you cannot use the ILanguage service
Added some support for setting cultures in API calls
Description
What did you add/update/change?
Type of suggestion
Product & version (if relevant)
Deadline (if relevant)
When should the content be published?