tr8n_core 4.0.6 → 4.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +11 -2
  3. data/lib/tr8n/api_client.rb +8 -0
  4. data/lib/tr8n/application.rb +8 -0
  5. data/lib/tr8n/base.rb +8 -0
  6. data/lib/tr8n/cache.rb +8 -0
  7. data/lib/tr8n/cache_adapters/cdb.rb +8 -0
  8. data/lib/tr8n/cache_adapters/file.rb +8 -0
  9. data/lib/tr8n/cache_adapters/memcache.rb +8 -0
  10. data/lib/tr8n/cache_adapters/redis.rb +9 -0
  11. data/lib/tr8n/component.rb +8 -0
  12. data/lib/tr8n/config.rb +8 -0
  13. data/lib/tr8n/decorators/base.rb +8 -0
  14. data/lib/tr8n/decorators/default.rb +8 -0
  15. data/lib/tr8n/decorators/html.rb +8 -0
  16. data/lib/tr8n/exception.rb +8 -0
  17. data/lib/tr8n/language.rb +8 -0
  18. data/lib/tr8n/language_case.rb +8 -0
  19. data/lib/tr8n/language_case_rule.rb +8 -0
  20. data/lib/tr8n/language_context.rb +8 -1
  21. data/lib/tr8n/language_context_rule.rb +8 -0
  22. data/lib/tr8n/logger.rb +8 -0
  23. data/lib/tr8n/rules_engine/evaluator.rb +8 -0
  24. data/lib/tr8n/rules_engine/parser.rb +8 -0
  25. data/lib/tr8n/session.rb +8 -0
  26. data/lib/tr8n/source.rb +8 -0
  27. data/lib/tr8n/tokens/data.rb +20 -14
  28. data/lib/tr8n/tokens/data_tokenizer.rb +8 -0
  29. data/lib/tr8n/tokens/decoration_tokenizer.rb +11 -22
  30. data/lib/tr8n/tokens/hidden.rb +8 -0
  31. data/lib/tr8n/tokens/method.rb +8 -0
  32. data/lib/tr8n/tokens/transform.rb +8 -0
  33. data/lib/tr8n/translation.rb +8 -0
  34. data/lib/tr8n/translation_key.rb +8 -0
  35. data/lib/tr8n/translator.rb +8 -0
  36. data/lib/tr8n/utils.rb +8 -0
  37. data/lib/tr8n_core/ext/array.rb +8 -0
  38. data/lib/tr8n_core/ext/date.rb +8 -0
  39. data/lib/tr8n_core/ext/fixnum.rb +8 -0
  40. data/lib/tr8n_core/ext/hash.rb +8 -0
  41. data/lib/tr8n_core/ext/string.rb +8 -0
  42. data/lib/tr8n_core/ext/time.rb +8 -0
  43. data/lib/tr8n_core/generators/cache/base.rb +8 -0
  44. data/lib/tr8n_core/generators/cache/cdb.rb +8 -0
  45. data/lib/tr8n_core/generators/cache/file.rb +8 -0
  46. data/lib/tr8n_core/version.rb +9 -2
  47. data/lib/tr8n_core.rb +9 -0
  48. data/spec/application_spec.rb +2 -2
  49. data/spec/cache/adapters/file_spec.rb +1 -1
  50. data/spec/cache/generators/file_generator_spec.rb +9 -9
  51. data/spec/config_spec.rb +3 -3
  52. data/spec/decorator_spec.rb +2 -0
  53. data/spec/ext/array_spec.rb +1 -1
  54. data/spec/ext/hash_spec.rb +1 -1
  55. data/spec/ext/string_spec.rb +1 -1
  56. data/spec/language_case_rule_spec.rb +8 -8
  57. data/spec/language_context_rule_spec.rb +16 -14
  58. data/spec/language_context_spec.rb +10 -8
  59. data/spec/language_spec.rb +1 -1
  60. data/spec/rules_engine/evaluator_spec.rb +52 -50
  61. data/spec/rules_engine/parser_spec.rb +2 -0
  62. data/spec/spec_helper.rb +7 -0
  63. data/spec/tokens/hidden_spec.rb +1 -1
  64. data/spec/tokens/method_spec.rb +4 -4
  65. data/spec/tokens/transform_spec.rb +4 -4
  66. data/spec/translation_key_spec.rb +1 -1
  67. data/spec/translation_spec.rb +1 -1
  68. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cb4ecbec7897fb75e2ed70e0490500b729ece962
4
- data.tar.gz: 3ddd6b6eb884f695f599c4f7d1f78cfda744572d
3
+ metadata.gz: c63616cd107057912d9e4751712da3a7b57f1d52
4
+ data.tar.gz: 39d042996c73c584256c6d68977e8ef05fb938ea
5
5
  SHA512:
6
- metadata.gz: 8451854a7e0a9e54fa0c7970f4e09f75f245cbeb4553cd13cc496a01a48134502cd977ac4ea00714401bddff5a25a7413d1440802b81792596a00c31dbcc17a2
7
- data.tar.gz: 5fccf44ca8a07e364c81d0c63a091a510a5fc0710e26588f5652e02b36fbca4a986b40182ba6490165fdc6b629fb4bf53dcfbc5b03d21bd338492900fa02e2f2
6
+ metadata.gz: 44f82a0d70a1dace61537bd714b77cdeabe30ca5eea5720753607de6218a1095d0e3642d6c31beb0dd607c6e87a503b1a7ab3d0c66cbd76ad57e76f07b36ba0a
7
+ data.tar.gz: 6d470e0719c0524271f14ab2e178a83e75dcbf65f45c10701fe7ed5350e227d505f59cbe4e0af3724bf4855a74cde3135c183675a843f9101626fa672e81481e
data/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  Tr8n Core Library For Ruby
6
6
  ==================
7
7
  [![Build Status](https://travis-ci.org/tr8n/tr8n_ruby_core.png?branch=master)](https://travis-ci.org/tr8n/tr8n_ruby_core)
8
- [![Coverage Status](https://coveralls.io/repos/tr8n/tr8n_ruby_core/badge.png)](https://coveralls.io/r/tr8n/tr8n_ruby_core)
8
+ [![Coverage Status](https://coveralls.io/repos/tr8n/tr8n_ruby_core/badge.png?branch=master)](https://coveralls.io/r/tr8n/tr8n_ruby_core?branch=master)
9
9
  [![Gem Version](https://badge.fury.io/rb/tr8n_core.png)](http://badge.fury.io/rb/tr8n_core)
10
10
  [![Dependency Status](https://www.versioneye.com/user/projects/52e36cc8ec1375c6f4000078/badge.png)](https://www.versioneye.com/user/projects/52e36cc8ec1375c6f4000078)
11
11
  [![Project status](http://stillmaintained.com/tr8n/tr8n_ruby_core.png)](http://stillmaintained.com/tr8n/tr8n_ruby_core.png)
@@ -35,6 +35,15 @@ gem install tr8n_core
35
35
  ```
36
36
 
37
37
 
38
+ Registering Your App
39
+ ===================================
40
+
41
+ Before you can proceed with the integration, please register with https://translationexchange.com and create a new application.
42
+
43
+ At the end of the registration process you will be given a key and a secret. You will need to enter them in the initialization function of the Tr8n SDK.
44
+
45
+
46
+
38
47
  Usage
39
48
  ==================
40
49
 
@@ -234,4 +243,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
234
243
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
235
244
  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
236
245
  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
237
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
246
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -2,6 +2,14 @@
2
2
  #--
3
3
  # Copyright (c) 2014 Michael Berkovich, TranslationExchange.com
4
4
  #
5
+ # _______ _ _ _ ______ _
6
+ # |__ __| | | | | (_) | ____| | |
7
+ # | |_ __ __ _ _ __ ___| | __ _| |_ _ ___ _ __ | |__ __ _____| |__ __ _ _ __ __ _ ___
8
+ # | | '__/ _` | '_ \/ __| |/ _` | __| |/ _ \| '_ \| __| \ \/ / __| '_ \ / _` | '_ \ / _` |/ _ \
9
+ # | | | | (_| | | | \__ \ | (_| | |_| | (_) | | | | |____ > < (__| | | | (_| | | | | (_| | __/
10
+ # |_|_| \__,_|_| |_|___/_|\__,_|\__|_|\___/|_| |_|______/_/\_\___|_| |_|\__,_|_| |_|\__, |\___|
11
+ # __/ |
12
+ # |___/
5
13
  # Permission is hereby granted, free of charge, to any person obtaining
6
14
  # a copy of this software and associated documentation files (the
7
15
  # "Software"), to deal in the Software without restriction, including
@@ -2,6 +2,14 @@
2
2
  #--
3
3
  # Copyright (c) 2014 Michael Berkovich, TranslationExchange.com
4
4
  #
5
+ # _______ _ _ _ ______ _
6
+ # |__ __| | | | | (_) | ____| | |
7
+ # | |_ __ __ _ _ __ ___| | __ _| |_ _ ___ _ __ | |__ __ _____| |__ __ _ _ __ __ _ ___
8
+ # | | '__/ _` | '_ \/ __| |/ _` | __| |/ _ \| '_ \| __| \ \/ / __| '_ \ / _` | '_ \ / _` |/ _ \
9
+ # | | | | (_| | | | \__ \ | (_| | |_| | (_) | | | | |____ > < (__| | | | (_| | | | | (_| | __/
10
+ # |_|_| \__,_|_| |_|___/_|\__,_|\__|_|\___/|_| |_|______/_/\_\___|_| |_|\__,_|_| |_|\__, |\___|
11
+ # __/ |
12
+ # |___/
5
13
  # Permission is hereby granted, free of charge, to any person obtaining
6
14
  # a copy of this software and associated documentation files (the
7
15
  # "Software"), to deal in the Software without restriction, including
data/lib/tr8n/base.rb CHANGED
@@ -2,6 +2,14 @@
2
2
  #--
3
3
  # Copyright (c) 2014 Michael Berkovich, TranslationExchange.com
4
4
  #
5
+ # _______ _ _ _ ______ _
6
+ # |__ __| | | | | (_) | ____| | |
7
+ # | |_ __ __ _ _ __ ___| | __ _| |_ _ ___ _ __ | |__ __ _____| |__ __ _ _ __ __ _ ___
8
+ # | | '__/ _` | '_ \/ __| |/ _` | __| |/ _ \| '_ \| __| \ \/ / __| '_ \ / _` | '_ \ / _` |/ _ \
9
+ # | | | | (_| | | | \__ \ | (_| | |_| | (_) | | | | |____ > < (__| | | | (_| | | | | (_| | __/
10
+ # |_|_| \__,_|_| |_|___/_|\__,_|\__|_|\___/|_| |_|______/_/\_\___|_| |_|\__,_|_| |_|\__, |\___|
11
+ # __/ |
12
+ # |___/
5
13
  # Permission is hereby granted, free of charge, to any person obtaining
6
14
  # a copy of this software and associated documentation files (the
7
15
  # "Software"), to deal in the Software without restriction, including
data/lib/tr8n/cache.rb CHANGED
@@ -2,6 +2,14 @@
2
2
  #--
3
3
  # Copyright (c) 2014 Michael Berkovich, TranslationExchange.com
4
4
  #
5
+ # _______ _ _ _ ______ _
6
+ # |__ __| | | | | (_) | ____| | |
7
+ # | |_ __ __ _ _ __ ___| | __ _| |_ _ ___ _ __ | |__ __ _____| |__ __ _ _ __ __ _ ___
8
+ # | | '__/ _` | '_ \/ __| |/ _` | __| |/ _ \| '_ \| __| \ \/ / __| '_ \ / _` | '_ \ / _` |/ _ \
9
+ # | | | | (_| | | | \__ \ | (_| | |_| | (_) | | | | |____ > < (__| | | | (_| | | | | (_| | __/
10
+ # |_|_| \__,_|_| |_|___/_|\__,_|\__|_|\___/|_| |_|______/_/\_\___|_| |_|\__,_|_| |_|\__, |\___|
11
+ # __/ |
12
+ # |___/
5
13
  # Permission is hereby granted, free of charge, to any person obtaining
6
14
  # a copy of this software and associated documentation files (the
7
15
  # "Software"), to deal in the Software without restriction, including
@@ -2,6 +2,14 @@
2
2
  #--
3
3
  # Copyright (c) 2014 Michael Berkovich, TranslationExchange.com
4
4
  #
5
+ # _______ _ _ _ ______ _
6
+ # |__ __| | | | | (_) | ____| | |
7
+ # | |_ __ __ _ _ __ ___| | __ _| |_ _ ___ _ __ | |__ __ _____| |__ __ _ _ __ __ _ ___
8
+ # | | '__/ _` | '_ \/ __| |/ _` | __| |/ _ \| '_ \| __| \ \/ / __| '_ \ / _` | '_ \ / _` |/ _ \
9
+ # | | | | (_| | | | \__ \ | (_| | |_| | (_) | | | | |____ > < (__| | | | (_| | | | | (_| | __/
10
+ # |_|_| \__,_|_| |_|___/_|\__,_|\__|_|\___/|_| |_|______/_/\_\___|_| |_|\__,_|_| |_|\__, |\___|
11
+ # __/ |
12
+ # |___/
5
13
  # Permission is hereby granted, free of charge, to any person obtaining
6
14
  # a copy of this software and associated documentation files (the
7
15
  # "Software"), to deal in the Software without restriction, including
@@ -2,6 +2,14 @@
2
2
  #--
3
3
  # Copyright (c) 2014 Michael Berkovich, TranslationExchange.com
4
4
  #
5
+ # _______ _ _ _ ______ _
6
+ # |__ __| | | | | (_) | ____| | |
7
+ # | |_ __ __ _ _ __ ___| | __ _| |_ _ ___ _ __ | |__ __ _____| |__ __ _ _ __ __ _ ___
8
+ # | | '__/ _` | '_ \/ __| |/ _` | __| |/ _ \| '_ \| __| \ \/ / __| '_ \ / _` | '_ \ / _` |/ _ \
9
+ # | | | | (_| | | | \__ \ | (_| | |_| | (_) | | | | |____ > < (__| | | | (_| | | | | (_| | __/
10
+ # |_|_| \__,_|_| |_|___/_|\__,_|\__|_|\___/|_| |_|______/_/\_\___|_| |_|\__,_|_| |_|\__, |\___|
11
+ # __/ |
12
+ # |___/
5
13
  # Permission is hereby granted, free of charge, to any person obtaining
6
14
  # a copy of this software and associated documentation files (the
7
15
  # "Software"), to deal in the Software without restriction, including
@@ -2,6 +2,14 @@
2
2
  #--
3
3
  # Copyright (c) 2014 Michael Berkovich, TranslationExchange.com
4
4
  #
5
+ # _______ _ _ _ ______ _
6
+ # |__ __| | | | | (_) | ____| | |
7
+ # | |_ __ __ _ _ __ ___| | __ _| |_ _ ___ _ __ | |__ __ _____| |__ __ _ _ __ __ _ ___
8
+ # | | '__/ _` | '_ \/ __| |/ _` | __| |/ _ \| '_ \| __| \ \/ / __| '_ \ / _` | '_ \ / _` |/ _ \
9
+ # | | | | (_| | | | \__ \ | (_| | |_| | (_) | | | | |____ > < (__| | | | (_| | | | | (_| | __/
10
+ # |_|_| \__,_|_| |_|___/_|\__,_|\__|_|\___/|_| |_|______/_/\_\___|_| |_|\__,_|_| |_|\__, |\___|
11
+ # __/ |
12
+ # |___/
5
13
  # Permission is hereby granted, free of charge, to any person obtaining
6
14
  # a copy of this software and associated documentation files (the
7
15
  # "Software"), to deal in the Software without restriction, including
@@ -2,6 +2,14 @@
2
2
  #--
3
3
  # Copyright (c) 2014 Michael Berkovich, TranslationExchange.com
4
4
  #
5
+ # _______ _ _ _ ______ _
6
+ # |__ __| | | | | (_) | ____| | |
7
+ # | |_ __ __ _ _ __ ___| | __ _| |_ _ ___ _ __ | |__ __ _____| |__ __ _ _ __ __ _ ___
8
+ # | | '__/ _` | '_ \/ __| |/ _` | __| |/ _ \| '_ \| __| \ \/ / __| '_ \ / _` | '_ \ / _` |/ _ \
9
+ # | | | | (_| | | | \__ \ | (_| | |_| | (_) | | | | |____ > < (__| | | | (_| | | | | (_| | __/
10
+ # |_|_| \__,_|_| |_|___/_|\__,_|\__|_|\___/|_| |_|______/_/\_\___|_| |_|\__,_|_| |_|\__, |\___|
11
+ # __/ |
12
+ # |___/
5
13
  # Permission is hereby granted, free of charge, to any person obtaining
6
14
  # a copy of this software and associated documentation files (the
7
15
  # "Software"), to deal in the Software without restriction, including
@@ -22,6 +30,7 @@
22
30
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
31
  #++
24
32
 
33
+
25
34
  require 'redis' if defined?(::Redis)
26
35
 
27
36
  class Tr8n::CacheAdapters::Redis < Tr8n::Cache
@@ -2,6 +2,14 @@
2
2
  #--
3
3
  # Copyright (c) 2014 Michael Berkovich, TranslationExchange.com
4
4
  #
5
+ # _______ _ _ _ ______ _
6
+ # |__ __| | | | | (_) | ____| | |
7
+ # | |_ __ __ _ _ __ ___| | __ _| |_ _ ___ _ __ | |__ __ _____| |__ __ _ _ __ __ _ ___
8
+ # | | '__/ _` | '_ \/ __| |/ _` | __| |/ _ \| '_ \| __| \ \/ / __| '_ \ / _` | '_ \ / _` |/ _ \
9
+ # | | | | (_| | | | \__ \ | (_| | |_| | (_) | | | | |____ > < (__| | | | (_| | | | | (_| | __/
10
+ # |_|_| \__,_|_| |_|___/_|\__,_|\__|_|\___/|_| |_|______/_/\_\___|_| |_|\__,_|_| |_|\__, |\___|
11
+ # __/ |
12
+ # |___/
5
13
  # Permission is hereby granted, free of charge, to any person obtaining
6
14
  # a copy of this software and associated documentation files (the
7
15
  # "Software"), to deal in the Software without restriction, including
data/lib/tr8n/config.rb CHANGED
@@ -2,6 +2,14 @@
2
2
  #--
3
3
  # Copyright (c) 2014 Michael Berkovich, TranslationExchange.com
4
4
  #
5
+ # _______ _ _ _ ______ _
6
+ # |__ __| | | | | (_) | ____| | |
7
+ # | |_ __ __ _ _ __ ___| | __ _| |_ _ ___ _ __ | |__ __ _____| |__ __ _ _ __ __ _ ___
8
+ # | | '__/ _` | '_ \/ __| |/ _` | __| |/ _ \| '_ \| __| \ \/ / __| '_ \ / _` | '_ \ / _` |/ _ \
9
+ # | | | | (_| | | | \__ \ | (_| | |_| | (_) | | | | |____ > < (__| | | | (_| | | | | (_| | __/
10
+ # |_|_| \__,_|_| |_|___/_|\__,_|\__|_|\___/|_| |_|______/_/\_\___|_| |_|\__,_|_| |_|\__, |\___|
11
+ # __/ |
12
+ # |___/
5
13
  # Permission is hereby granted, free of charge, to any person obtaining
6
14
  # a copy of this software and associated documentation files (the
7
15
  # "Software"), to deal in the Software without restriction, including
@@ -2,6 +2,14 @@
2
2
  #--
3
3
  # Copyright (c) 2014 Michael Berkovich, TranslationExchange.com
4
4
  #
5
+ # _______ _ _ _ ______ _
6
+ # |__ __| | | | | (_) | ____| | |
7
+ # | |_ __ __ _ _ __ ___| | __ _| |_ _ ___ _ __ | |__ __ _____| |__ __ _ _ __ __ _ ___
8
+ # | | '__/ _` | '_ \/ __| |/ _` | __| |/ _ \| '_ \| __| \ \/ / __| '_ \ / _` | '_ \ / _` |/ _ \
9
+ # | | | | (_| | | | \__ \ | (_| | |_| | (_) | | | | |____ > < (__| | | | (_| | | | | (_| | __/
10
+ # |_|_| \__,_|_| |_|___/_|\__,_|\__|_|\___/|_| |_|______/_/\_\___|_| |_|\__,_|_| |_|\__, |\___|
11
+ # __/ |
12
+ # |___/
5
13
  # Permission is hereby granted, free of charge, to any person obtaining
6
14
  # a copy of this software and associated documentation files (the
7
15
  # "Software"), to deal in the Software without restriction, including
@@ -2,6 +2,14 @@
2
2
  #--
3
3
  # Copyright (c) 2014 Michael Berkovich, TranslationExchange.com
4
4
  #
5
+ # _______ _ _ _ ______ _
6
+ # |__ __| | | | | (_) | ____| | |
7
+ # | |_ __ __ _ _ __ ___| | __ _| |_ _ ___ _ __ | |__ __ _____| |__ __ _ _ __ __ _ ___
8
+ # | | '__/ _` | '_ \/ __| |/ _` | __| |/ _ \| '_ \| __| \ \/ / __| '_ \ / _` | '_ \ / _` |/ _ \
9
+ # | | | | (_| | | | \__ \ | (_| | |_| | (_) | | | | |____ > < (__| | | | (_| | | | | (_| | __/
10
+ # |_|_| \__,_|_| |_|___/_|\__,_|\__|_|\___/|_| |_|______/_/\_\___|_| |_|\__,_|_| |_|\__, |\___|
11
+ # __/ |
12
+ # |___/
5
13
  # Permission is hereby granted, free of charge, to any person obtaining
6
14
  # a copy of this software and associated documentation files (the
7
15
  # "Software"), to deal in the Software without restriction, including
@@ -2,6 +2,14 @@
2
2
  #--
3
3
  # Copyright (c) 2014 Michael Berkovich, TranslationExchange.com
4
4
  #
5
+ # _______ _ _ _ ______ _
6
+ # |__ __| | | | | (_) | ____| | |
7
+ # | |_ __ __ _ _ __ ___| | __ _| |_ _ ___ _ __ | |__ __ _____| |__ __ _ _ __ __ _ ___
8
+ # | | '__/ _` | '_ \/ __| |/ _` | __| |/ _ \| '_ \| __| \ \/ / __| '_ \ / _` | '_ \ / _` |/ _ \
9
+ # | | | | (_| | | | \__ \ | (_| | |_| | (_) | | | | |____ > < (__| | | | (_| | | | | (_| | __/
10
+ # |_|_| \__,_|_| |_|___/_|\__,_|\__|_|\___/|_| |_|______/_/\_\___|_| |_|\__,_|_| |_|\__, |\___|
11
+ # __/ |
12
+ # |___/
5
13
  # Permission is hereby granted, free of charge, to any person obtaining
6
14
  # a copy of this software and associated documentation files (the
7
15
  # "Software"), to deal in the Software without restriction, including
@@ -2,6 +2,14 @@
2
2
  #--
3
3
  # Copyright (c) 2014 Michael Berkovich, TranslationExchange.com
4
4
  #
5
+ # _______ _ _ _ ______ _
6
+ # |__ __| | | | | (_) | ____| | |
7
+ # | |_ __ __ _ _ __ ___| | __ _| |_ _ ___ _ __ | |__ __ _____| |__ __ _ _ __ __ _ ___
8
+ # | | '__/ _` | '_ \/ __| |/ _` | __| |/ _ \| '_ \| __| \ \/ / __| '_ \ / _` | '_ \ / _` |/ _ \
9
+ # | | | | (_| | | | \__ \ | (_| | |_| | (_) | | | | |____ > < (__| | | | (_| | | | | (_| | __/
10
+ # |_|_| \__,_|_| |_|___/_|\__,_|\__|_|\___/|_| |_|______/_/\_\___|_| |_|\__,_|_| |_|\__, |\___|
11
+ # __/ |
12
+ # |___/
5
13
  # Permission is hereby granted, free of charge, to any person obtaining
6
14
  # a copy of this software and associated documentation files (the
7
15
  # "Software"), to deal in the Software without restriction, including
data/lib/tr8n/language.rb CHANGED
@@ -2,6 +2,14 @@
2
2
  #--
3
3
  # Copyright (c) 2014 Michael Berkovich, TranslationExchange.com
4
4
  #
5
+ # _______ _ _ _ ______ _
6
+ # |__ __| | | | | (_) | ____| | |
7
+ # | |_ __ __ _ _ __ ___| | __ _| |_ _ ___ _ __ | |__ __ _____| |__ __ _ _ __ __ _ ___
8
+ # | | '__/ _` | '_ \/ __| |/ _` | __| |/ _ \| '_ \| __| \ \/ / __| '_ \ / _` | '_ \ / _` |/ _ \
9
+ # | | | | (_| | | | \__ \ | (_| | |_| | (_) | | | | |____ > < (__| | | | (_| | | | | (_| | __/
10
+ # |_|_| \__,_|_| |_|___/_|\__,_|\__|_|\___/|_| |_|______/_/\_\___|_| |_|\__,_|_| |_|\__, |\___|
11
+ # __/ |
12
+ # |___/
5
13
  # Permission is hereby granted, free of charge, to any person obtaining
6
14
  # a copy of this software and associated documentation files (the
7
15
  # "Software"), to deal in the Software without restriction, including
@@ -2,6 +2,14 @@
2
2
  #--
3
3
  # Copyright (c) 2014 Michael Berkovich, TranslationExchange.com
4
4
  #
5
+ # _______ _ _ _ ______ _
6
+ # |__ __| | | | | (_) | ____| | |
7
+ # | |_ __ __ _ _ __ ___| | __ _| |_ _ ___ _ __ | |__ __ _____| |__ __ _ _ __ __ _ ___
8
+ # | | '__/ _` | '_ \/ __| |/ _` | __| |/ _ \| '_ \| __| \ \/ / __| '_ \ / _` | '_ \ / _` |/ _ \
9
+ # | | | | (_| | | | \__ \ | (_| | |_| | (_) | | | | |____ > < (__| | | | (_| | | | | (_| | __/
10
+ # |_|_| \__,_|_| |_|___/_|\__,_|\__|_|\___/|_| |_|______/_/\_\___|_| |_|\__,_|_| |_|\__, |\___|
11
+ # __/ |
12
+ # |___/
5
13
  # Permission is hereby granted, free of charge, to any person obtaining
6
14
  # a copy of this software and associated documentation files (the
7
15
  # "Software"), to deal in the Software without restriction, including
@@ -2,6 +2,14 @@
2
2
  #--
3
3
  # Copyright (c) 2014 Michael Berkovich, TranslationExchange.com
4
4
  #
5
+ # _______ _ _ _ ______ _
6
+ # |__ __| | | | | (_) | ____| | |
7
+ # | |_ __ __ _ _ __ ___| | __ _| |_ _ ___ _ __ | |__ __ _____| |__ __ _ _ __ __ _ ___
8
+ # | | '__/ _` | '_ \/ __| |/ _` | __| |/ _ \| '_ \| __| \ \/ / __| '_ \ / _` | '_ \ / _` |/ _ \
9
+ # | | | | (_| | | | \__ \ | (_| | |_| | (_) | | | | |____ > < (__| | | | (_| | | | | (_| | __/
10
+ # |_|_| \__,_|_| |_|___/_|\__,_|\__|_|\___/|_| |_|______/_/\_\___|_| |_|\__,_|_| |_|\__, |\___|
11
+ # __/ |
12
+ # |___/
5
13
  # Permission is hereby granted, free of charge, to any person obtaining
6
14
  # a copy of this software and associated documentation files (the
7
15
  # "Software"), to deal in the Software without restriction, including
@@ -2,6 +2,14 @@
2
2
  #--
3
3
  # Copyright (c) 2014 Michael Berkovich, TranslationExchange.com
4
4
  #
5
+ # _______ _ _ _ ______ _
6
+ # |__ __| | | | | (_) | ____| | |
7
+ # | |_ __ __ _ _ __ ___| | __ _| |_ _ ___ _ __ | |__ __ _____| |__ __ _ _ __ __ _ ___
8
+ # | | '__/ _` | '_ \/ __| |/ _` | __| |/ _ \| '_ \| __| \ \/ / __| '_ \ / _` | '_ \ / _` |/ _ \
9
+ # | | | | (_| | | | \__ \ | (_| | |_| | (_) | | | | |____ > < (__| | | | (_| | | | | (_| | __/
10
+ # |_|_| \__,_|_| |_|___/_|\__,_|\__|_|\___/|_| |_|______/_/\_\___|_| |_|\__,_|_| |_|\__, |\___|
11
+ # __/ |
12
+ # |___/
5
13
  # Permission is hereby granted, free of charge, to any person obtaining
6
14
  # a copy of this software and associated documentation files (the
7
15
  # "Software"), to deal in the Software without restriction, including
@@ -22,7 +30,6 @@
22
30
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
31
  #++
24
32
 
25
-
26
33
  class Tr8n::LanguageContext < Tr8n::Base
27
34
  belongs_to :language
28
35
  attributes :keyword, :description, :default_key, :token_expression, :variables, :token_mapping
@@ -2,6 +2,14 @@
2
2
  #--
3
3
  # Copyright (c) 2014 Michael Berkovich, TranslationExchange.com
4
4
  #
5
+ # _______ _ _ _ ______ _
6
+ # |__ __| | | | | (_) | ____| | |
7
+ # | |_ __ __ _ _ __ ___| | __ _| |_ _ ___ _ __ | |__ __ _____| |__ __ _ _ __ __ _ ___
8
+ # | | '__/ _` | '_ \/ __| |/ _` | __| |/ _ \| '_ \| __| \ \/ / __| '_ \ / _` | '_ \ / _` |/ _ \
9
+ # | | | | (_| | | | \__ \ | (_| | |_| | (_) | | | | |____ > < (__| | | | (_| | | | | (_| | __/
10
+ # |_|_| \__,_|_| |_|___/_|\__,_|\__|_|\___/|_| |_|______/_/\_\___|_| |_|\__,_|_| |_|\__, |\___|
11
+ # __/ |
12
+ # |___/
5
13
  # Permission is hereby granted, free of charge, to any person obtaining
6
14
  # a copy of this software and associated documentation files (the
7
15
  # "Software"), to deal in the Software without restriction, including
data/lib/tr8n/logger.rb CHANGED
@@ -2,6 +2,14 @@
2
2
  #--
3
3
  # Copyright (c) 2014 Michael Berkovich, TranslationExchange.com
4
4
  #
5
+ # _______ _ _ _ ______ _
6
+ # |__ __| | | | | (_) | ____| | |
7
+ # | |_ __ __ _ _ __ ___| | __ _| |_ _ ___ _ __ | |__ __ _____| |__ __ _ _ __ __ _ ___
8
+ # | | '__/ _` | '_ \/ __| |/ _` | __| |/ _ \| '_ \| __| \ \/ / __| '_ \ / _` | '_ \ / _` |/ _ \
9
+ # | | | | (_| | | | \__ \ | (_| | |_| | (_) | | | | |____ > < (__| | | | (_| | | | | (_| | __/
10
+ # |_|_| \__,_|_| |_|___/_|\__,_|\__|_|\___/|_| |_|______/_/\_\___|_| |_|\__,_|_| |_|\__, |\___|
11
+ # __/ |
12
+ # |___/
5
13
  # Permission is hereby granted, free of charge, to any person obtaining
6
14
  # a copy of this software and associated documentation files (the
7
15
  # "Software"), to deal in the Software without restriction, including
@@ -2,6 +2,14 @@
2
2
  #--
3
3
  # Copyright (c) 2014 Michael Berkovich, TranslationExchange.com
4
4
  #
5
+ # _______ _ _ _ ______ _
6
+ # |__ __| | | | | (_) | ____| | |
7
+ # | |_ __ __ _ _ __ ___| | __ _| |_ _ ___ _ __ | |__ __ _____| |__ __ _ _ __ __ _ ___
8
+ # | | '__/ _` | '_ \/ __| |/ _` | __| |/ _ \| '_ \| __| \ \/ / __| '_ \ / _` | '_ \ / _` |/ _ \
9
+ # | | | | (_| | | | \__ \ | (_| | |_| | (_) | | | | |____ > < (__| | | | (_| | | | | (_| | __/
10
+ # |_|_| \__,_|_| |_|___/_|\__,_|\__|_|\___/|_| |_|______/_/\_\___|_| |_|\__,_|_| |_|\__, |\___|
11
+ # __/ |
12
+ # |___/
5
13
  # Permission is hereby granted, free of charge, to any person obtaining
6
14
  # a copy of this software and associated documentation files (the
7
15
  # "Software"), to deal in the Software without restriction, including
@@ -2,6 +2,14 @@
2
2
  #--
3
3
  # Copyright (c) 2014 Michael Berkovich, TranslationExchange.com
4
4
  #
5
+ # _______ _ _ _ ______ _
6
+ # |__ __| | | | | (_) | ____| | |
7
+ # | |_ __ __ _ _ __ ___| | __ _| |_ _ ___ _ __ | |__ __ _____| |__ __ _ _ __ __ _ ___
8
+ # | | '__/ _` | '_ \/ __| |/ _` | __| |/ _ \| '_ \| __| \ \/ / __| '_ \ / _` | '_ \ / _` |/ _ \
9
+ # | | | | (_| | | | \__ \ | (_| | |_| | (_) | | | | |____ > < (__| | | | (_| | | | | (_| | __/
10
+ # |_|_| \__,_|_| |_|___/_|\__,_|\__|_|\___/|_| |_|______/_/\_\___|_| |_|\__,_|_| |_|\__, |\___|
11
+ # __/ |
12
+ # |___/
5
13
  # Permission is hereby granted, free of charge, to any person obtaining
6
14
  # a copy of this software and associated documentation files (the
7
15
  # "Software"), to deal in the Software without restriction, including
data/lib/tr8n/session.rb CHANGED
@@ -2,6 +2,14 @@
2
2
  #--
3
3
  # Copyright (c) 2014 Michael Berkovich, TranslationExchange.com
4
4
  #
5
+ # _______ _ _ _ ______ _
6
+ # |__ __| | | | | (_) | ____| | |
7
+ # | |_ __ __ _ _ __ ___| | __ _| |_ _ ___ _ __ | |__ __ _____| |__ __ _ _ __ __ _ ___
8
+ # | | '__/ _` | '_ \/ __| |/ _` | __| |/ _ \| '_ \| __| \ \/ / __| '_ \ / _` | '_ \ / _` |/ _ \
9
+ # | | | | (_| | | | \__ \ | (_| | |_| | (_) | | | | |____ > < (__| | | | (_| | | | | (_| | __/
10
+ # |_|_| \__,_|_| |_|___/_|\__,_|\__|_|\___/|_| |_|______/_/\_\___|_| |_|\__,_|_| |_|\__, |\___|
11
+ # __/ |
12
+ # |___/
5
13
  # Permission is hereby granted, free of charge, to any person obtaining
6
14
  # a copy of this software and associated documentation files (the
7
15
  # "Software"), to deal in the Software without restriction, including
data/lib/tr8n/source.rb CHANGED
@@ -2,6 +2,14 @@
2
2
  #--
3
3
  # Copyright (c) 2014 Michael Berkovich, TranslationExchange.com
4
4
  #
5
+ # _______ _ _ _ ______ _
6
+ # |__ __| | | | | (_) | ____| | |
7
+ # | |_ __ __ _ _ __ ___| | __ _| |_ _ ___ _ __ | |__ __ _____| |__ __ _ _ __ __ _ ___
8
+ # | | '__/ _` | '_ \/ __| |/ _` | __| |/ _ \| '_ \| __| \ \/ / __| '_ \ / _` | '_ \ / _` |/ _ \
9
+ # | | | | (_| | | | \__ \ | (_| | |_| | (_) | | | | |____ > < (__| | | | (_| | | | | (_| | __/
10
+ # |_|_| \__,_|_| |_|___/_|\__,_|\__|_|\___/|_| |_|______/_/\_\___|_| |_|\__,_|_| |_|\__, |\___|
11
+ # __/ |
12
+ # |___/
5
13
  # Permission is hereby granted, free of charge, to any person obtaining
6
14
  # a copy of this software and associated documentation files (the
7
15
  # "Software"), to deal in the Software without restriction, including
@@ -2,6 +2,14 @@
2
2
  #--
3
3
  # Copyright (c) 2014 Michael Berkovich, TranslationExchange.com
4
4
  #
5
+ # _______ _ _ _ ______ _
6
+ # |__ __| | | | | (_) | ____| | |
7
+ # | |_ __ __ _ _ __ ___| | __ _| |_ _ ___ _ __ | |__ __ _____| |__ __ _ _ __ __ _ ___
8
+ # | | '__/ _` | '_ \/ __| |/ _` | __| |/ _ \| '_ \| __| \ \/ / __| '_ \ / _` | '_ \ / _` |/ _ \
9
+ # | | | | (_| | | | \__ \ | (_| | |_| | (_) | | | | |____ > < (__| | | | (_| | | | | (_| | __/
10
+ # |_|_| \__,_|_| |_|___/_|\__,_|\__|_|\___/|_| |_|______/_/\_\___|_| |_|\__,_|_| |_|\__, |\___|
11
+ # __/ |
12
+ # |___/
5
13
  # Permission is hereby granted, free of charge, to any person obtaining
6
14
  # a copy of this software and associated documentation files (the
7
15
  # "Software"), to deal in the Software without restriction, including
@@ -134,7 +142,7 @@ module Tr8n
134
142
  #
135
143
  #
136
144
  ##############################################################################
137
- def token_value_from_array(params, language, options)
145
+ def token_values_from_array(params, language, options)
138
146
  list_options = {
139
147
  :description => "List joiner",
140
148
  :limit => 4,
@@ -180,10 +188,11 @@ module Tr8n
180
188
  end
181
189
 
182
190
  return values.first if objects.size == 1
183
- return values.join(list_options[:separator]) unless list_options[:joiner]
191
+ return values.join(list_options[:separator]) if list_options[:joiner].nil? || list_options[:joiner] == ""
184
192
 
193
+ joiner = language.translate(list_options[:joiner], list_options[:description], {}, options)
185
194
  if values.size <= list_options[:limit]
186
- return "#{values[0..-2].join(list_options[:separator])} #{language.translate(list_options[:joiner], list_options[:description], {}, options)} #{values.last}"
195
+ return "#{values[0..-2].join(list_options[:separator])} #{joiner} #{values.last}"
187
196
  end
188
197
 
189
198
  display_ary = values[0..(list_options[:limit]-1)]
@@ -191,7 +200,7 @@ module Tr8n
191
200
  result = "#{display_ary.join(list_options[:separator])}"
192
201
 
193
202
  unless list_options[:expandable]
194
- result << " " << language.translate(list_options[:joiner], list_options[:description], {}, options) << " "
203
+ result << " " << joiner << " "
195
204
  if list_options[:remainder] and list_options[:remainder].is_a?(Proc)
196
205
  result << list_options[:remainder].call(remaining_ary)
197
206
  else
@@ -200,11 +209,8 @@ module Tr8n
200
209
  return result
201
210
  end
202
211
 
203
- joiner = language.translate(list_options[:joiner], list_options[:description], {}, options)
204
-
205
212
  uniq_id = Tr8n::TranslationKey.generate_key(label, values.join(","))
206
- result << "<span id=\"tr8n_other_link_#{uniq_id}\">"
207
- result << " #{joiner} "
213
+ result << "<span id=\"tr8n_other_link_#{uniq_id}\"> #{joiner} "
208
214
 
209
215
  result << "<a href='#' onClick=\"Tr8n.Utils.Effects.hide('tr8n_other_link_#{uniq_id}'); Tr8n.Utils.Effects.show('tr8n_other_elements_#{uniq_id}'); return false;\">"
210
216
  if list_options[:remainder] and list_options[:remainder].is_a?(Proc)
@@ -243,7 +249,7 @@ module Tr8n
243
249
  #
244
250
  ##############################################################################
245
251
 
246
- def token_value_from_param_array(array, language, options)
252
+ def token_value_from_array_param(array, language, options)
247
253
  # if you provided an array, it better have some values
248
254
  if array.size < 2
249
255
  Tr8n.logger.error("Invalid value for array token #{full_name} in #{label}")
@@ -252,14 +258,14 @@ module Tr8n
252
258
 
253
259
  # if the first value of an array is an array handle it here
254
260
  if array[0].is_a?(Array)
255
- return token_value_from_array(array, language, options)
261
+ return token_values_from_array(array, language, options)
256
262
  end
257
263
 
258
264
  if array[1].is_a?(String)
259
265
  return sanitize(array[1], array[0], language, options.merge(:safe => true))
260
266
  end
261
267
 
262
- if array[1].is_a?(Hash)
268
+ if array[0].is_a?(Hash)
263
269
  if array[1].is_a?(Symbol)
264
270
  return sanitize(Tr8n::Utils.hash_value(array[0], array[1]), array[0], language, options.merge(:safe => false))
265
271
  end
@@ -293,7 +299,7 @@ module Tr8n
293
299
  #
294
300
  ##############################################################################
295
301
 
296
- def token_value_from_param_hash(hash, language, options)
302
+ def token_value_from_hash_param(hash, language, options)
297
303
  value = Tr8n::Utils.hash_value(hash, :value)
298
304
  object = Tr8n::Utils.hash_value(hash, :object)
299
305
 
@@ -322,8 +328,8 @@ module Tr8n
322
328
 
323
329
  # evaluate all possible methods for the token value and return sanitized result
324
330
  def token_value(object, language, options = {})
325
- return token_value_from_param_array(object, language, options) if object.is_a?(Array)
326
- return token_value_from_param_hash(object, language, options) if object.is_a?(Hash)
331
+ return token_value_from_array_param(object, language, options) if object.is_a?(Array)
332
+ return token_value_from_hash_param(object, language, options) if object.is_a?(Hash)
327
333
  sanitize(object, object, language, options)
328
334
  end
329
335
 
@@ -2,6 +2,14 @@
2
2
  #--
3
3
  # Copyright (c) 2014 Michael Berkovich, TranslationExchange.com
4
4
  #
5
+ # _______ _ _ _ ______ _
6
+ # |__ __| | | | | (_) | ____| | |
7
+ # | |_ __ __ _ _ __ ___| | __ _| |_ _ ___ _ __ | |__ __ _____| |__ __ _ _ __ __ _ ___
8
+ # | | '__/ _` | '_ \/ __| |/ _` | __| |/ _ \| '_ \| __| \ \/ / __| '_ \ / _` | '_ \ / _` |/ _ \
9
+ # | | | | (_| | | | \__ \ | (_| | |_| | (_) | | | | |____ > < (__| | | | (_| | | | | (_| | __/
10
+ # |_|_| \__,_|_| |_|___/_|\__,_|\__|_|\___/|_| |_|______/_/\_\___|_| |_|\__,_|_| |_|\__, |\___|
11
+ # __/ |
12
+ # |___/
5
13
  # Permission is hereby granted, free of charge, to any person obtaining
6
14
  # a copy of this software and associated documentation files (the
7
15
  # "Software"), to deal in the Software without restriction, including
@@ -2,6 +2,14 @@
2
2
  #--
3
3
  # Copyright (c) 2014 Michael Berkovich, TranslationExchange.com
4
4
  #
5
+ # _______ _ _ _ ______ _
6
+ # |__ __| | | | | (_) | ____| | |
7
+ # | |_ __ __ _ _ __ ___| | __ _| |_ _ ___ _ __ | |__ __ _____| |__ __ _ _ __ __ _ ___
8
+ # | | '__/ _` | '_ \/ __| |/ _` | __| |/ _ \| '_ \| __| \ \/ / __| '_ \ / _` | '_ \ / _` |/ _ \
9
+ # | | | | (_| | | | \__ \ | (_| | |_| | (_) | | | | |____ > < (__| | | | (_| | | | | (_| | __/
10
+ # |_|_| \__,_|_| |_|___/_|\__,_|\__|_|\___/|_| |_|______/_/\_\___|_| |_|\__,_|_| |_|\__, |\___|
11
+ # __/ |
12
+ # |___/
5
13
  # Permission is hereby granted, free of charge, to any person obtaining
6
14
  # a copy of this software and associated documentation files (the
7
15
  # "Software"), to deal in the Software without restriction, including
@@ -121,36 +129,17 @@ module Tr8n
121
129
  end
122
130
 
123
131
  default_decoration = default_decoration.clone
124
- decoration_token_values = context[token_name.to_sym] || context[token_name.to_s] || []
132
+ decoration_token_values = context[token_name.to_sym] || context[token_name.to_s]
125
133
 
126
- if decoration_token_values.is_a?(Array)
127
- params = [token_value, decoration_token_values].flatten
128
- params.each_with_index do |param, index|
129
- default_decoration.gsub!("{$#{index}}", param.to_s)
130
- end
131
-
132
- # clean all the rest of the {$num} params, if any
133
- param_index = params.size
134
- while default_decoration.index("{$#{param_index}}")
135
- default_decoration.gsub!("{$#{param_index}}", "")
136
- param_index += 1
137
- end
138
-
139
- return default_decoration
140
- end
134
+ default_decoration.gsub!("{$0}", token_value.to_s)
141
135
 
142
136
  if decoration_token_values.is_a?(Hash)
143
- default_decoration.gsub!("{$0}", token_value.to_s)
144
-
145
137
  decoration_token_values.keys.each do |key|
146
138
  default_decoration.gsub!("{$#{key}}", decoration_token_values[key].to_s)
147
139
  end
148
-
149
- return default_decoration
150
140
  end
151
141
 
152
- Tr8n.logger.error("Don't know how to process decoration token value for #{token_name} in #{text}")
153
- token_value
142
+ default_decoration
154
143
  end
155
144
 
156
145
  def allowed_token?(token)