|
Revision 84, 0.9 kB
(checked in by saimon, 2 years ago)
|
--Backporting for-1.2 features
|
| Line | |
|---|
| 1 |
module Globalize |
|---|
| 2 |
# Represents a view translation in the DB, which is a translation of a string |
|---|
| 3 |
# in the rails application itself. This includes error messages, controllers, |
|---|
| 4 |
# views, and flashes, but not database content. |
|---|
| 5 |
class ViewTranslation < Translation # :nodoc: |
|---|
| 6 |
|
|---|
| 7 |
def self.pick(key, language, idx, namespace = nil) |
|---|
| 8 |
conditions = 'tr_key = ? AND language_id = ? AND pluralization_index = ?' |
|---|
| 9 |
namespace_condition = namespace ? ' AND namespace = ?' : ' AND namespace IS NULL' |
|---|
| 10 |
conditions << namespace_condition |
|---|
| 11 |
find(:first, :conditions => [conditions,*[key, language.id, idx, namespace].compact]) |
|---|
| 12 |
end |
|---|
| 13 |
|
|---|
| 14 |
#Find all namespaces used in translations |
|---|
| 15 |
def self.find_all_namespaces |
|---|
| 16 |
sql = <<-SQL |
|---|
| 17 |
SELECT distinct(namespace) FROM globalize_translations order by namespace |
|---|
| 18 |
SQL |
|---|
| 19 |
self.connection.select_values(sql).compact |
|---|
| 20 |
end |
|---|
| 21 |
|
|---|
| 22 |
end |
|---|
| 23 |
end |
|---|