Closed morgrowe closed 3 years ago
Hi @morgrowe , glad to see you again :)
For MVC you need to add [Route]
attribute to the actions:
public class HomeController : Controller
{
private readonly ILogger<HomeController> _logger;
public HomeController(ILogger<HomeController> logger)
{
_logger = logger;
}
[Route("")]
public IActionResult Index()
{
return View();
}
[Route("Privacy")]
public IActionResult Privacy()
{
return View();
}
}
Hi Ziya
Thank you, as always, for your quick response. Adding the Route decorators fixed that issue. :)
I have one final problem and I can't for the life of me figure out what's doing on.
I have seeded by database with the cultures and some dummy resources:
It doesn't seem to be localizing strings unless the culture is set to my secondary one: cy
. My default is en
. So if I go to /
, or /en
the culture is correctly being set to en
but the string isn't being localized:
However, if I go to /cy
, it does get localized:
Any idea what's going on there? I bet I've misconfigured something in my Startup.cs
. I haven't changed it since my original post.
Cheers Morgan
Hi @morgrowe
Actually this is already reported in a previous issue #19, I can't say it is a bug, but a design issue that needs enhancement.
I didn't publish an update yet, but it seems time is already came to fix this :)
I see! That makes sense. I agree it's not a bug, but it would be great to add the option mentioned in #19 to support key codes. I look forward to the update. :)
Thanks Morgan
And for DB version update to XLocalizer.DB v1.0.2
Brilliant, thanks Ziya :)
Hi Ziya,
Hope you're well.
I've successfully added XLocalizer.DB to a RazorPages project, but I'm having issues adding it to an existing Mvc project. Despite changes I've tried to make, I either get the 'AmbiguousActionException' exception or the route localization doesn't work at all. It's a very simple project with only one controller.
Here's the Startup.cs:
And the
Index
method in theHomeController
is very straight forward:I've got the exception to go away by removing:
and
and updating my
MapRoute
to:But doing this ignores the culture in the URL--it always returns "en", even if "cy" is in the URL.
Any guidance would be really appreciated. I'm more than likely doing something silly again.
Cheers Morgan