Hacker News new | ask | show | jobs
by waleedka 2947 days ago
One idea you might want to consider is to create a global function, let’s call it h() and pass all your human readable strings through it, like so h(“hello world”). This function, simply returns the same string. This is more explicit than relying on quote types. It also allows you to do interesting things such as logging everything to a text file and running a spell checker on it, or checking for wrongly encoded string, ...etc.
3 comments

I believe _() would be even better, granted you might want to translate messages in future. At first might just def _(s): return s.
A single underscore is pretty much de facto reserved for localization.
Which is exactly what this is. Putting everything a human reads into a function is step one of localization.
That's pretty standard in libraries that do i18n (like Qt, for example). It's a very good practice IMO. Not only does it enable i18n, it means you can easily collect every user-destined string and check it for things like forbidden words etc.
Yep, as others have commented, this is what I meant by using the translation tools.