Skip to content
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

Use locale from config if specified, otherwise use user's environment locale #1378

Closed

Conversation

micahellison
Copy link
Member

@micahellison micahellison commented Nov 20, 2021

Fixes #1353 by checking the config file for a locale setting. If there's no locale setting, then it uses the environment's locale instead.

🚨 Affects both the presentation and storage of dates! 🚨

I'm also going to keep this as a draft until I:

  • add documentation about this feature
    • include some "gotchas" around Windows vs other environments - from my testing, it seems like Windows only uses the Control Panel's language setting, instead of any environment variables
  • address concerns around automatically fetching the locale and possibly messing with the dates on existing journals (maybe only an issue for people that use %c in their timeformat?) - I don't want every entry between the 1st and 12th day of the month to suddenly get its date mangled because someone is switching their environment between en_US and en_GB, for instance
  • add additional tests?
  • possibly force locale in test code with mocks so that "make test" works right out of the box regardless of the developer's locale
  • gracefully deal with unsupported locales instead of spewing a stack trace

If anyone else would like to work any of the above, feel free to contribute. I'll mainly be working on this on Saturdays, Pacific time.

Checklist

  • I have read the contributing doc.
  • I have included a link to the relevant issue number.
  • I have checked to ensure there aren't other open pull requests
    for the same issue.
  • I have written new tests for these changes, as needed.

@micahellison
Copy link
Member Author

Finally got a basic test working on Windows and Mac after learning--to my horror!--that strftime('%c') has different behavior across OSes even if the locale is the same. Even more specific format specifiers can vary, like %A (the day of the week) which has varying capitalizations in French.

However, Ubuntu is still failing because it doesn't seem to have any of these languages. I think I either need to a) find a locale on our Ubuntu CI setup that isn't en_US, or b) install those locales before running tests. Maybe I'll tackle that next weekend.

@micahellison
Copy link
Member Author

I'm closing this since I haven't made any progress on this for six months and I don't think I'm going to return to this. However, if you're working on this issue and have any questions, please feel free to @ me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted More help wanted from a contributor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

jrnl doesn't use OS's locale settings when displaying time
1 participant