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

More robust i18n try3 #558

Closed
wants to merge 3 commits into from
Closed

Conversation

godiard
Copy link
Contributor

@godiard godiard commented Jul 23, 2015

Replaces #557

We have received a few reports of broken ~/.i18n files
Try to make the code more robust, using "with" to open the files,
and remove redundancy in the code.
Only write the file when set the languages, and flush to
try avoid have a broken file.
When read the languages, get the values from the enviroment variables
set on bin/sugar. If the file ~/.i18n exists, was already read there.
When the user press the cancel button in the control panel section,
the ModelWrapper object (in gui.py) try to revert the changes
and write the initial values, even if nothing has changed.
As the recording of the values is triggered by a timeout,
we don't have another way to avoid race contions that verify
at the moment of write the file.
…#4878

When the user press the (+) button and a new language row is added,
the _add_row method receive locale_code=None. To make the method
manage this case properly, we need do two changes:
* Do not check in the available locales because None will not get any value.
* When add the locale_code to self._country_codes,
  set the locale based in the default values displayed to the user.

A consequence of the method not managing the None case,
id that changes will not be saved until the user change the default
value displayed to the user.
@godiard
Copy link
Contributor Author

godiard commented Jul 23, 2015

@samdroid-apps, I addressed your comments in the next patch (Before open....)


try:
with open(path, 'w') as fd:
fd.write(new_lang_line)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 105 to 110 do not preserve previous unrelated contents of file. Since the file can contain locale environment variables like currency and date format, this is impolite to other software. 😄

@godiard godiard mentioned this pull request Jul 27, 2015
@godiard
Copy link
Contributor Author

godiard commented Jul 27, 2015

Replaced by #560

@godiard godiard closed this Jul 27, 2015
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.

None yet

3 participants