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

Added the ability to specify translations for the default language #2909

Closed
wants to merge 1 commit into from
Closed

Added the ability to specify translations for the default language #2909

wants to merge 1 commit into from

Conversation

LaurentGoderre
Copy link
Contributor

Allows to override the default language without modifying the templates

Allows to override the default language without modifying the templates
@amercader
Copy link
Member

@LaurentGoderre could you give more context about why this is needed and what is the effect of this PR?

@LaurentGoderre
Copy link
Contributor Author

This allows changing english ckan strings without modifying all the templates where they are defined. For example, it was requested that we change all instance of the word dataset to the word record. Instead of changing all the 200+ templates where it occurs, this takes care of that requirement.

Most people probably won't need this but it's a neat feature to have.

@amercader amercader self-assigned this Mar 15, 2016

try:
i18n.set_lang(lang, pylons_config=fake_config, class_=Translations)
except i18n.LanguageError:
Copy link
Member

Choose a reason for hiding this comment

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

We were not capturing and ignoring these before, is this needed by the new behaviour (supporting en)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Basically, if you don't have an english override, it triggers that exception saying 'english is not found'. So by trapping it this way, if there is no english override or if they use a missing language, it will revert to the default language

@joetsoi
Copy link
Contributor

joetsoi commented Apr 26, 2016

@LaurentGoderre, changing "Dataset" to "Record" should have already been possible by using ckan.i18n.extra_directory and dropping an extra translation file in. Or by adding an english translation in your extension there's an example one in ckanext folder. It was used a few times to just change the "Organization" string and we used it in ckanext-showcase if I recall.

What is your default language set as, it's possible there is a slight different case which I didn't account for when I wrote this.

@LaurentGoderre
Copy link
Contributor Author

The english translation file are ignored because they are the default without this changed

@joetsoi
Copy link
Contributor

joetsoi commented Apr 26, 2016

If english is default, then there should be no translation object in pylons , this case should be handled by
https://github.com/ckan/ckan/blob/master/ckan/lib/i18n.py#L164-L173 which adds the the extra translations you provide as the default.

I'll take a look again as it's been a while since I looked at this.

@LaurentGoderre
Copy link
Contributor Author

If you can show me some code that makes it work it would be appreciated. I couldn't get it to work

@tino097
Copy link
Member

tino097 commented Aug 30, 2018

@khayo36 please check the docs http://docs.ckan.org/en/2.8/contributing/i18n.html

@kmbn
Copy link
Contributor

kmbn commented Jan 22, 2019

We decided to close old pull requests that are not actively worked on so that we can focus our effort and attention on PRs made against the current version of CKAN. A lot has changed in the last several months and many PRs will have gone stale or may now be in conflict with the latest version.

Please note: this isn't a judgement about the quality of your pull request. We just don't have the resources to review older PRs.

If you would like to reopen your PR (and update it if necessary), please do!

@kmbn kmbn closed this Jan 22, 2019
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

6 participants