Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upAdd language detection #1772
Conversation
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Gargron
Apr 14, 2017
Member
Hmm, surprised about PG::NotNullViolation tbh, I had the impression if a passed value is null and the column is not null, the default value would be used....
|
Hmm, surprised about |
Gargron
changed the title from
[WIP] Add language detection
to
Add language detection
Apr 15, 2017
| @@ -230,6 +231,10 @@ def content(xml = @xml) | ||
| xml.at_xpath('./xmlns:content', xmlns: TagManager::XMLNS).content | ||
| end | ||
| + def content_language(xml = @xml) | ||
| + xml.at_xpath('./xmlns:content', xmlns: TagManager::XMLNS)['xml:lang']&.presence || 'en' |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
mjankowski
Apr 16, 2017
Collaborator
Should that be hardcoded to en as default, or should it use whatever I18n.default_locale is?
mjankowski
Apr 16, 2017
Collaborator
Should that be hardcoded to en as default, or should it use whatever I18n.default_locale is?
| @@ -0,0 +1,5 @@ | ||
| +class AddLanguageToStatuses < ActiveRecord::Migration[5.0] | ||
| + def change | ||
| + add_column :statuses, :language, :string, null: false, default: 'en' |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
mjankowski
Apr 16, 2017
Collaborator
Will this make all historical statuses on an instance retroactively call themselves en ?
mjankowski
Apr 16, 2017
Collaborator
Will this make all historical statuses on an instance retroactively call themselves en ?
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Gargron
Apr 16, 2017
Member
Yep, it will. That's the status quo - all current statuses are in the same pool
Gargron
Apr 16, 2017
Member
Yep, it will. That's the status quo - all current statuses are in the same pool
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
mjankowski
Apr 16, 2017
Collaborator
Is that true for a server running with a different default locale?
Like, if an admin has bothered to set a different default locale value, it might be a safe assumption that the statuses created on that instance are in that locale, and that this migration should use that value instead of hardcoding en?
When this is deployed it will be run on each instance separately, so it might be "more correct" to make the assumption based on that (ie, are the instances running in Japan, Hong Kong, etc - primarily using en or other locale?)
mjankowski
Apr 16, 2017
Collaborator
Is that true for a server running with a different default locale?
Like, if an admin has bothered to set a different default locale value, it might be a safe assumption that the statuses created on that instance are in that locale, and that this migration should use that value instead of hardcoding en?
When this is deployed it will be run on each instance separately, so it might be "more correct" to make the assumption based on that (ie, are the instances running in Japan, Hong Kong, etc - primarily using en or other locale?)
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
mjankowski
Apr 16, 2017
Collaborator
Side question to the actual changes here, is this change being made in future support of something like - #1094 ?
|
Side question to the actual changes here, is this change being made in future support of something like - #1094 ? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Gargron
Apr 16, 2017
Member
Yeah, pretty much, although unsure which UI path I'll take. But getting the language attribute out to clients via the API is first step - would allow some to display a "translate" button conditionally, perhaps.
|
Yeah, pretty much, although unsure which UI path I'll take. But getting the language attribute out to clients via the API is first step - would allow some to display a "translate" button conditionally, perhaps. |
Gargron commentedApr 14, 2017
What else must be done? Expose language attribute in JSON API? Language filters for public timelines?