Skip to content

Make localized by removing all previous locales #32

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Davoodeh
Copy link

This bit of code removes all the reinvented wheels of localization and replaces them with the langinfo method (optionally).

Since langinfo is pretty much standard at this point, there is no need to check for it, yet the code is written in a modular way to discard the feature if needed (for very limited environments perhaps, in the future).

The previous implementation had numerous problems:

  • branches are too many and covering the code is hard (if there is any plans for tests in the future)
  • indeed the string slicing is wrong and the attempts made are prone to error
  • there is no way to localize the values (example on Update jtime.c #8 where one user liked a lesser known alternative to Jomeh, this is especially important since the style of Persian's transliteration is a topic of hot debate)

Limitations of this implementation as of now:

  • since everything is just plain str and slicing Unicode is a whole other issue, localized outputs may be formatted incorrectly when not ASCII. Maybe wchar must be replaced for a better handling as it helps the developers with sound and tested predefined unicode functions and utilities.
  • fa_IR locale is flawed and needs correction in some places (I may push on that front too) for example am_pm is not set (glibc 2.41, "Persian does not have the 12-hour format"1!!??#?!?? and other questionable lines to blame with no easy to access documentation on why). This is obviously not an issue with the code but since this code depends on that data, it's something to consider.

All-in-all, having this and the Python code removed, the codebase tested and documented will breathe a new life into the project imho. Man pages, "docs" and many other bloated "features" in this code need to go and I will remove them in future commits.

This code is not extensively tested and requires careful reviewing. But since there are no automated tests, it's better to make these radical changes now rather than when wider adoption (#27) has taken place. Hence, I'll push this now so all of us can go on with more issues to solve.

This bit of code removes all the reinvented wheels of localization and
replaces them with the langinfo method (optionally).

Since langinfo is pretty much standard at this point, there is no need
to check for it, yet the code is written in a modular way to discard the
feature if needed (for very limited environments perhaps, in the
future).

The previous implementation had numerous problems:
- branches are too many and covering the code is hard (if there is any
  plans for tests in the future)
- indeed the string slicing is wrong and the attempts made are prone to
  error
- there is no way to localize the values (example on persiancal#8 where one user
  liked a lesser known alternative to Jomeh, this is especially
  important since the style of Persian's transliteration is a topic of
  hot debate)

Limitations of this implementation as of now:
- since everything is just plain str and slicing Unicode is a whole
  other issue, localized outputs may be formatted incorrectly when not
  ASCII. Maybe `wchar` must be replaced for a better handling as it
  helps the developers with sound and tested predefined unicode
  functions and utilities.
- `fa_IR` locale is flawed and needs correction in some places (I may
  push on that front too) for example `am_pm` is not set (glibc 2.41,
  "Persian does not have the 12-hour format"[1]!!??#?!?? and other
  questionable lines to `blame` with no easy to access documentation on
  why). This is obviously not an issue with the code but since this
  code depends on that data, it's something to consider.

All-in-all, having this and the Python code removed, the codebase tested
and documented will breathe a new life into the project imho. Man pages,
"docs" and many other bloated "features" in this code need to go and I
will remove them in future commits.

This code is not extensively tested and requires careful reviewing. But
since there are no automated tests, it's better to make these radical
changes now rather than when wider adoption (persiancal#27) has taken place.
Hence, I'll push this now so all of us can go on with more issues to
solve.

[1]:
https://sourceware.org/git?p=glibc.git;a=blob;f=localedata/locales/fa_IR;h=aa0dd188006a1b24feda1e311bf015ec6f128700;hb=HEAD#l325
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant