Official Localization / Internationalization support

I just started my first serious Vapor project using the latest Vapor (4.29.3). After setting up my basic model & controller layer, I want to start testing it, including localized validation error messages to be shown to the user. But I can't find any documentation on localization, not even a mention of the topic for further reading in the official docs.

Searching for "vapor localization" on Google only brings up a third party dependency (Lingo-Vapor), searching through GitHub Issues also only brings up very old discussions from over 3 years ago which in the end point to the same third party dependency (e.g. #1105), searching through the Vapor category here in this forum doesn't even result in a single thread which has localization as it's topic.

I am really confused now, am I missing something? Why is no one else missing native localization support in Vapor? Is there something official everyone is waiting for from the Swift Server Group? I can't find localization mentioned in their last annual update. Or is everyone using the Vapor-Lingo library? If yes, why does it only have 35 stars & so few collaborators leading to new Vapor versions supported way too late (e.g. 4 months after final Vapor 4 release)? Isn't localization such an important feature of a web framework that it should be included into it natively with a flexible & simple-to-use API?

I think the main reason nothings exists at the moment is because no one has built it. I'd say there isn't a huge demand at the moment because most of the Swift server work has been focused on APIs rather than client facing modules.

That said I think adding localisation support to Leaf would be awesome.

@0xTim If you read my original post closely, I'm also one of those who use Vapor for building an API. That doesn't mean I don't need localization though, as I've stated something simple as localized errors already needs localization. How would localization support for Leaf help out there? Not at all.

I think we need a more general and flexible support and once we have that, one further step would be to integrate this into Leaf as well. But I'm also talking about things like support for default or common HTTP headers (e.g. Accept-Language) and URL query parameters (e.g. locale/lang) which I'd turn on by default, then of course proper handling of time zones, units & formatting (the basics are already part of Foundation with TimeZone, Measurement and DateFormatter, we just need to use them automatically or make it easy at least).

Of course, some of this can also be solved by simply documenting how you can setup your Vapor app to react to such things like different languages, time zones, units & regional formatting rules. But at the moment there's no awareness and documentation at all, also the basic localization support needs to be baked in as there's no default there in Swift. So if nothing else, I'd at least expect a guide on localization which points to the already existing Lingo library and gives some examples on how one could use Accept-Language and similar things, as well as mentioning links for further reading on Measurement, TimeZone and DateFormatter to help people out.

Please note that I'm not only concerned about people who already have some backend experience in other frameworks and can translate the experiences there over to Vapor. I'm mostly concerned about the wave of iOS developers who are going to try building an entire backend API or even a website with Vapor and they will at some point get stuck because they don't find any ways to solve these common problems. And the fact that no one complained yet just shows that these people didn't even think about localization (case 1) or that they abandoned Vapor quickly anyways because it's still missing basic things like localization and didn't see (case 2). At least I can't think of any other cases ...

By the way, I just came across SE-0278 again which we should probably make use of and can get us inspired by when implementing a native localization support in Vapor.

Terms of Service

Privacy Policy

Cookie Policy