Commit 041494a8fa882035a21951a5668d63da90b3574c
1 parent
6569e61a
Exists in
master
and in
27 other branches
metadata: Use alternate languages from article
Showing
2 changed files
with
6 additions
and
2 deletions
Show diff stats
app/models/article.rb
@@ -390,6 +390,10 @@ class Article < ActiveRecord::Base | @@ -390,6 +390,10 @@ class Article < ActiveRecord::Base | ||
390 | {} | 390 | {} |
391 | end | 391 | end |
392 | 392 | ||
393 | + def alternate_languages | ||
394 | + self.translations.map(&:language) | ||
395 | + end | ||
396 | + | ||
393 | scope :native_translations, :conditions => { :translation_of_id => nil } | 397 | scope :native_translations, :conditions => { :translation_of_id => nil } |
394 | 398 | ||
395 | def translatable? | 399 | def translatable? |
plugins/metadata/lib/ext/article.rb
@@ -15,8 +15,8 @@ class Article | @@ -15,8 +15,8 @@ class Article | ||
15 | see_also: [], | 15 | see_also: [], |
16 | site_name: proc{ |a, c| a.profile.name }, | 16 | site_name: proc{ |a, c| a.profile.name }, |
17 | updated_time: proc{ |a, c| a.updated_at.iso8601 }, | 17 | updated_time: proc{ |a, c| a.updated_at.iso8601 }, |
18 | - 'locale:locale' => proc{ |a, c| a.environment.default_language }, | ||
19 | - 'locale:alternate' => proc{ |a, c| a.environment.languages - [a.environment.default_language] }, | 18 | + 'locale:locale' => proc{ |a, c| a.language || a.environment.default_language }, |
19 | + 'locale:alternate' => proc{ |a, c| a.alternate_languages }, | ||
20 | 20 | ||
21 | description: proc{ |a, plugin| ActionView::Base.full_sanitizer.sanitize a.body }, | 21 | description: proc{ |a, plugin| ActionView::Base.full_sanitizer.sanitize a.body }, |
22 | rich_attachment: "", | 22 | rich_attachment: "", |