I'd like to add a small helper similar to build_localized_fieldname, but that would only return the lang part.
I've been needing this in several parts of my projects, and think had to either use build_localized_fieldname("", lang)[1:] or do it manually, using a simple lang.replace("-", "_"), but in that case I lose the id case handling.
I think this need seems quite common, so why not make it a dedicated helper?
Something like this (the method name is not great - if you have any better idea):
def build_lang(lang: str) -> str:
if lang == "id":
# The 2-letter Indonesian language code is problematic with the
# current naming scheme as Django foreign keys also add "id" suffix.
lang = "ind"
return lang.replace("-", "_")
I'd be happy to make a PR if you think it could be merged!
Just let me know :)
Hey there,
I'd like to add a small helper similar to
build_localized_fieldname
, but that would only return the lang part. I've been needing this in several parts of my projects, and think had to either usebuild_localized_fieldname("", lang)[1:]
or do it manually, using a simplelang.replace("-", "_")
, but in that case I lose theid
case handling. I think this need seems quite common, so why not make it a dedicated helper? Something like this (the method name is not great - if you have any better idea):I'd be happy to make a PR if you think it could be merged! Just let me know :)