@@ -83,7 +83,7 @@ def translatable?(field)
83
83
# @param [Symbol] tag tag to enclose field translation
84
84
# @param [Symbol] initial_locale locale to set as not hidden
85
85
def field_translations ( field , tag , initial_locale )
86
- @record . translations . map do |translation |
86
+ available_translations . map do |translation |
87
87
# Classes for translation span only first element is visible
88
88
css_classes = [ 'field-translation' , "locale-#{ translation . locale } " ]
89
89
# Initially only element for selected locale is visible
@@ -98,7 +98,7 @@ def field_translations(field, tag, initial_locale)
98
98
99
99
def block_locale_selectors
100
100
content_tag ( :ul , class : 'available-locales locale-selector' ) do
101
- @record . translations . map ( &:locale ) . map do |locale |
101
+ available_translations . map ( &:locale ) . map do |locale |
102
102
default = 'default' if locale == I18n . default_locale
103
103
content_tag ( :li , class : 'translation-tab' ) do
104
104
I18n . with_locale ( locale ) do
@@ -112,13 +112,17 @@ def block_locale_selectors
112
112
# Return flag elements to show the given locale using javascript
113
113
def inline_locale_selectors
114
114
content_tag ( :span , class : 'inline-locale-selector' ) do
115
- @record . translations . map do |translation |
115
+ available_translations . map do |translation |
116
116
# Build a link to show the given translation
117
117
link_to ( flag_icon ( translation . locale ) , '#' , class : 'ui-translation-trigger' , data : { locale : translation . locale } )
118
118
end . join ( ' ' ) . html_safe
119
119
end
120
120
end
121
121
122
+ def available_translations
123
+ @record_translations ||= @record . translations . order ( :locale )
124
+ end
125
+
122
126
end
123
127
end
124
128
end
0 commit comments