tml 4.4.4 → 4.4.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2e07af13388f61b41b40c25cea4be7bc7896430c
4
- data.tar.gz: c9d05b304a9a4e48f79b38e4b9217ebabac954f0
3
+ metadata.gz: 2ee215776a93a3de80da5b0f4f432ea99e44e577
4
+ data.tar.gz: b2dd1de37941aaef3224de6a2458cbf5cc74c6ca
5
5
  SHA512:
6
- metadata.gz: 1369334f7c7f1bbfcb269f8af6e1f8325b37ce9c15d0ec2c97a5bf18b71c06011865e9a3fc777c8247c0752bd1ac534c38f87611f963afafa4493dded031d7b8
7
- data.tar.gz: fc82f9eed90fd0ae94afea07651efd26c5ac8eee4feb017b95150b43ca0fc08d2503a324500dd78c2d3e160575a83bbc45d552bac25b25257b6e2dae3e412b0f
6
+ metadata.gz: 6a3a8087e25ca982bcc9ed6ed27e74ac53bac437738512bbe1a754f9d23e0ea82e3aaceeae1a6ae425cf53767ff558454a868985b09ff14cbc11a2510ba313a0
7
+ data.tar.gz: cc3e5c6524a9690e774a31b3aeefeae710a567b67e1e98bd03cf99b3f12799b7c71a4e75b105cc11e0b0fa8c7ab14115a10436d332b631b2f2d849caeac687d6
@@ -209,6 +209,7 @@ class Tml::Application < Tml::Base
209
209
  Tml::Translation.new(
210
210
  :locale => t['locale'] || locale,
211
211
  :label => t['label'],
212
+ :locked => t['locked'],
212
213
  :context => t['context']
213
214
  )
214
215
  end
@@ -76,6 +76,7 @@ module Tml
76
76
  class Config
77
77
  # Configuration Attributes
78
78
  attr_accessor :enabled, :locale, :default_level, :format, :application, :context_rules, :logger, :cache, :default_tokens, :localization
79
+ attr_accessor :auto_init
79
80
 
80
81
  # Used by Rails and Sinatra extensions
81
82
  attr_accessor :current_locale_method, :current_user_method, :translator_options, :i18n_backend
@@ -89,6 +90,7 @@ module Tml
89
90
  @default_level = 0
90
91
  @format = :html
91
92
  @subdomains = false
93
+ @auto_init = true
92
94
 
93
95
  @locale = {
94
96
  default: 'en',
@@ -41,11 +41,10 @@ class Tml::Decorators::Html < Tml::Decorators::Base
41
41
  # if translation key language is the same as target language - skip decorations
42
42
  return translated_label if translation_key.language == target_language
43
43
  return translated_label unless inline_mode?
44
- return translated_label if translation_key.locked? and not Tml.session.current_translator.manager?
45
44
 
46
45
  classes = %w(tml_translatable)
47
-
48
- if translation_key.locked?
46
+
47
+ if options[:locked]
49
48
  # must be a manager and enabling locking feature
50
49
  # return translated_label unless Tml.session.current_translator.feature_enabled?(:show_locked_keys)
51
50
  classes << 'tml_locked'
@@ -153,6 +153,10 @@ class Tml::Language < Tml::Base
153
153
  return translation_key.translate(self, params[:tokens], params[:options]).tml_translated
154
154
  end
155
155
 
156
+ if options[:dynamic] or Tml.session.block_options[:dynamic]
157
+
158
+ end
159
+
156
160
  source_key = current_source(options)
157
161
 
158
162
  source = application.source(source_key, locale)
@@ -84,6 +84,7 @@ class Tml::Source < Tml::Base
84
84
  Tml::Translation.new(
85
85
  :locale => t['locale'] || locale,
86
86
  :label => t['label'],
87
+ :locked => t['locked'],
87
88
  :context => t['context']
88
89
  )
89
90
  end
@@ -44,6 +44,8 @@
44
44
  # [link: {count||message}]
45
45
  # [link: {count||person, people}]
46
46
  # [link: {user.name}]
47
+ # [link] {user.name} [/link]
48
+ # <link> {user.name} </link>
47
49
  #
48
50
  #######################################################################
49
51
 
@@ -57,12 +59,14 @@ module Tml
57
59
 
58
60
  RE_SHORT_TOKEN_START = '\[[\w]*:'
59
61
  RE_SHORT_TOKEN_END = '\]'
60
- RE_LONG_TOKEN_START = '\[[\w]*\]'
61
- RE_LONG_TOKEN_END = '\[\/[\w]*\]'
62
- RE_TEXT = '[^\[\]]+' #'[\w\s!.:{}\(\)\|,?]*'
62
+ RE_LONG_TOKEN_START = '\[[\w]*\]' # [link]
63
+ RE_LONG_TOKEN_END = '\[\/[\w]*\]' # [/link]
64
+ RE_HTML_TOKEN_START = '<[^\>]*>' # <link>
65
+ RE_HTML_TOKEN_END = '<\/[^\>]*>' # </link>
66
+ RE_TEXT = '[^\[\]<>]+' # '[\w\s!.:{}\(\)\|,?]*'
63
67
 
64
68
  def self.required?(label)
65
- label.index('[')
69
+ label.index('[') or label.index('<')
66
70
  end
67
71
 
68
72
  def initialize(text, context = {}, opts = {})
@@ -77,6 +81,8 @@ module Tml
77
81
  RE_SHORT_TOKEN_END,
78
82
  RE_LONG_TOKEN_START,
79
83
  RE_LONG_TOKEN_END,
84
+ RE_HTML_TOKEN_START,
85
+ RE_HTML_TOKEN_END,
80
86
  RE_TEXT].join('|')
81
87
  @fragments = text.scan(/#{re}/)
82
88
  @tokens = []
@@ -94,6 +100,11 @@ module Tml
94
100
  return parse_tree(token.gsub(/[\[\]]/, ''), :long)
95
101
  end
96
102
 
103
+ if token.match(/#{RE_HTML_TOKEN_START}/)
104
+ return token if token.index('/>')
105
+ return parse_tree(token.gsub(/[<>]/, '').split(' ').first, :html)
106
+ end
107
+
97
108
  token.to_s
98
109
  end
99
110
 
@@ -115,6 +126,10 @@ module Tml
115
126
  until fragments.first.nil? or fragments.first.match(/#{RE_LONG_TOKEN_END}/)
116
127
  tree << parse
117
128
  end
129
+ elsif type == :html
130
+ until fragments.first.nil? or fragments.first.match(/#{RE_HTML_TOKEN_END}/)
131
+ tree << parse
132
+ end
118
133
  end
119
134
 
120
135
  fragments.shift
@@ -196,7 +211,7 @@ module Tml
196
211
  end
197
212
 
198
213
  def substitute
199
- evaluate(parse)
214
+ evaluate(parse).gsub('[/tml]', '')
200
215
  end
201
216
 
202
217
  end
@@ -37,7 +37,7 @@ module Tml
37
37
  attr_reader :label, :full_name, :short_name, :case_keys, :context_keys
38
38
 
39
39
  def self.expression
40
- /(\{[^_:][\w]*(:[\w]+)*(::[\w]+)*\})/
40
+ /(%?\{{1,2}\s*\w*\s*(:\s*\w+)*\s*(::\s*\w+)*\s*\}{1,2})/
41
41
  end
42
42
 
43
43
  def self.parse(label, opts = {})
@@ -41,7 +41,7 @@
41
41
 
42
42
  class Tml::Tokens::Method < Tml::Tokens::Data
43
43
  def self.expression
44
- /(\{[^_:.][\w]*(\.[\w]+)(:[\w]+)*(::[\w]+)*\})/
44
+ /(%?\{{1,2}\s*[\w]*\.\w*\s*(:\s*\w+)*\s*(::\s*\w+)*\s*\}{1,2})/
45
45
  end
46
46
 
47
47
  def object_name
@@ -57,7 +57,7 @@ class Tml::Tokens::Transform < Tml::Tokens::Data
57
57
  attr_reader :pipe_separator, :piped_params
58
58
 
59
59
  def self.expression
60
- /(\{[^_:|][\w]*(:[\w]+)*(::[\w]+)*\s*\|\|?[^{^}]+\})/
60
+ /(%?\{{1,2}\s*[\w]*\s*(:\s*\w+)*\s*\|\|?[^\{\}\|]+\}{1,2})/
61
61
  end
62
62
 
63
63
  def parse_elements
@@ -32,7 +32,7 @@
32
32
 
33
33
  class Tml::Translation < Tml::Base
34
34
  belongs_to :translation_key, :language
35
- attributes :locale, :label, :context, :precedence
35
+ attributes :locale, :label, :context, :precedence, :locked
36
36
 
37
37
  def has_context_rules?
38
38
  context and context.any?
@@ -34,7 +34,7 @@ require 'digest/md5'
34
34
 
35
35
  class Tml::TranslationKey < Tml::Base
36
36
  belongs_to :application, :language
37
- attributes :id, :key, :label, :description, :locale, :level, :locked
37
+ attributes :id, :key, :label, :description, :locale, :level
38
38
  has_many :translations # hashed by language
39
39
 
40
40
  def initialize(attrs = {})
@@ -118,6 +118,7 @@ class Tml::TranslationKey < Tml::Base
118
118
  decorator = Tml::Decorators::Base.decorator
119
119
 
120
120
  if translation
121
+ options[:locked] = translation.locked
121
122
  translated_label = substitute_tokens(translation.label, token_values, translation.language, options)
122
123
  return decorator.decorate(translated_label, translation.language, language, self, options)
123
124
  end
@@ -164,14 +165,14 @@ class Tml::TranslationKey < Tml::Base
164
165
  end
165
166
 
166
167
  def substitute_tokens(translated_label, token_values, language, options = {})
167
- if Tml::Tokenizers::Data.required?(translated_label)
168
- translated_label = Tml::Tokenizers::Data.new(translated_label, token_values, :allowed_tokens => data_tokens_names_map).substitute(language, options)
169
- end
170
-
171
168
  if Tml::Tokenizers::Decoration.required?(translated_label)
172
169
  translated_label = Tml::Tokenizers::Decoration.new(translated_label, token_values, :allowed_tokens => decoration_tokens).substitute
173
170
  end
174
171
 
172
+ if Tml::Tokenizers::Data.required?(translated_label)
173
+ translated_label = Tml::Tokenizers::Data.new(translated_label, token_values, :allowed_tokens => data_tokens_names_map).substitute(language, options)
174
+ end
175
+
175
176
  translated_label
176
177
  end
177
178
 
@@ -30,5 +30,5 @@
30
30
  #++
31
31
 
32
32
  module Tml
33
- VERSION = '4.4.4'
33
+ VERSION = '4.4.7'
34
34
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tml
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.4.4
4
+ version: 4.4.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Berkovich
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-24 00:00:00.000000000 Z
11
+ date: 2015-07-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday