Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/tr8n/extensions/string_extension.rb
Overview
– Copyright © 2010-2012 Michael Berkovich, tr8n.net
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ++
Instance Method Summary collapse
- #pluralize_for(count, plural = nil) ⇒ Object
- #tr8n_translated ⇒ Object
- #tr8n_translated? ⇒ Boolean
- #translate(desc = "", tokens = {}, options = {}, language = Tr8n::Config.current_language) ⇒ Object
- #trl(desc = "", tokens = {}, options = {}, language = Tr8n::Config.current_language) ⇒ Object
Instance Method Details
#pluralize_for(count, plural = nil) ⇒ Object
30 31 32 33 |
# File 'lib/tr8n/extensions/string_extension.rb', line 30 def pluralize_for(count, plural = nil) return self if count==1 plural || pluralize end |
#tr8n_translated ⇒ Object
39 40 41 42 43 |
# File 'lib/tr8n/extensions/string_extension.rb', line 39 def tr8n_translated return self if frozen? @tr8n_translated = true self.html_safe end |
#tr8n_translated? ⇒ Boolean
45 46 47 |
# File 'lib/tr8n/extensions/string_extension.rb', line 45 def tr8n_translated? @tr8n_translated end |
#translate(desc = "", tokens = {}, options = {}, language = Tr8n::Config.current_language) ⇒ Object
26 27 28 |
# File 'lib/tr8n/extensions/string_extension.rb', line 26 def translate(desc = "", tokens = {}, = {}, language = Tr8n::Config.current_language) language.translate(self, desc, tokens, ) end |
#trl(desc = "", tokens = {}, options = {}, language = Tr8n::Config.current_language) ⇒ Object
35 36 37 |
# File 'lib/tr8n/extensions/string_extension.rb', line 35 def trl(desc = "", tokens = {}, = {}, language = Tr8n::Config.current_language) translate(desc, tokens, .merge(:skip_decorations => true), language) end |