Project

General

Profile

Feature #1143 » localizable.rb

Support for auto language - Tiemo Vorschuetz, 2016-02-25 21:01

 
1
# encoding: UTF-8
2

    
3
# Copyright © Emilio González Montaña
4
# Licence: Attribution & no derivates
5
#   * Attribution to the plugin web page URL should be done if you want to use it.
6
#     https://redmine.ociotec.com/projects/localizable
7
#   * No derivates of this plugin (or partial) are allowed.
8
# Take a look to licence.txt file at plugin root folder for further details.
9

    
10
class Localizable < ApplicationController
11

    
12
  def self.localize(type, id, name)
13
    value = name
14
    lang = current_language;
15
    unless Setting["plugin_localizable"].nil?
16
      unless Setting["plugin_localizable"]["locales"].nil?
17
        unless Setting["plugin_localizable"]["locales"][type].nil?
18
          unless Setting["plugin_localizable"]["locales"][type][id.to_s].nil?
19
            unless Setting["plugin_localizable"]["locales"][type][id.to_s][lang].blank?
20
              value = Setting["plugin_localizable"]["locales"][type][id.to_s][lang]
21
            end
22
          end
23
        end
24
      end
25
    end
26
    return(value)
27
  end
28
end
    (1-1/1)