Skip to content
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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

jonathoncove2
Copy link

@jonathoncove2 jonathoncove2 commented Aug 19, 2024

Added some support for setting cultures in API calls

Description

What did you add/update/change?

Type of suggestion

  • Typo/grammar fix
  • Updated outdated content
  • New content
  • Updates related to a new version
  • Other

Product & version (if relevant)

Deadline (if relevant)

When should the content be published?

Added some support for setting cultures in API calls
@eshanrnh
Copy link
Contributor

Thanks for the PR, @jonathoncove2 🙌 We will review it as soon as we can. 💪

@sofietoft
Copy link
Contributor

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.
Instead, a fit for this code of yours, could be in the "Creating a multilingual site" instead?
Let me know what you think.
I'll make sure we have the code reviewed in the meantime 💪

@jonathoncove2
Copy link
Author

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?

@sofietoft
Copy link
Contributor

Excellent!
No need for a new PR, I think. Just put the code in the other article instead, then we're golden ⭐

It would be amazing with a language switcher 👏
We've actually had that on an internal to-do list for ages, just never had the time to prioritize it.

The "Create a multilingual site" tutorial is a bit long and messy at the moment.
But if you could add your stuff where you think it makes sense, then I'll make sure we give it a look afterward - might need a bit of restructuring and perhaps it could even be split into multiple sub-articles 🤔

Added a guide for creating a basic language switching navigation
@jonathoncove2
Copy link
Author

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.

@sofietoft
Copy link
Contributor

Amazing @jonathoncove2 !
I'll make sure we take a look at it as soon as possible 💪

Have a wonderful holiday 🏖️

Copy link
Contributor

@Frost117 Frost117 left a 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;
Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


#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.
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants