Write # in yaml (in the string) - syntax

I'm new using yml files (for translations in my framework).
I'm trying to add a "#" inside the translation (will be a twitter share... blabla).
Is this possible, because the file translate it like a comment...

Just put the value inside single or double quotes and it won't be treated like a comment. Something like:
en:
twitter:
share: "#hashtag"

Related

How to put single quote and double quote in post filename

Is it possible to use special characters like single and double quote in yml front matter
Post file name are used to represent the link to the post, so having a file my-post.md will result in /my-post link. Putting quotes there is a bad idea - quotes in the link will be html encoded - so link won't look nice, and it will make your life harder dealing with files with quotes.
I assume you're missing the yml front matter feature - you can name your file with a simple name, but have a title in your post with any character you want:
---
title: W'ha"t e!veR T?<tle## y04 w4nt
---
If I use double quote I need to use > in title like
title: >
A winter's "day"

How does the # work in Bash?

When I open BashBurn source I se:
mainmenu[7]="$bb_menu_8#check_path"
I don't know what does #check_path mean? And how does it work?
It doesn't mean any special in Bash alone: # is just a part of a string here. It could have a special meaning inside the BashBurn implementation, however.
It looks like it is a part of the translation framework used inside BashBurn. You can search it on your own on GitHub for example.
mainmenu is set in BashBurn.sh, which is then passed as the second argument to the bbmenu function. The function is defined in bbmenu.sh. There is a description of the syntax, including this information:
ALL ITEMS ARE SEPERATED BY AMPERSAND.
All you need to do now is to read the rest of the documentation in the bbmenu.sh file.

breakable slashes everywhere but URLs

I generate pdf (latex) from restructured text using python sphinx (1.4.6) .
I use narrow table column headers with texts like "stuff/misc/other". I need the slashes to be breakable, so the table headers don't overflow into the next column.
The LaTeX solution is to use \BreakableSlash or \slash where necessary. I can use python code to replace all slashes:
from sphinx.util.texescape import tex_replacements
# \BreakableSlash needs package hyphenat to be loaded
tex_replacements.append((u'/', ur'\BreakableSlash ') )
# tex_replacements.append((u'/', ur'\slash ') )
But that will break any URL like http://www.example.com/ into something like
http:\unhbox\voidb#x\penalty\#M\hskip\z#skip/\discretionary{-}{}{}\penalty\#M\hskip\z#skip\unhbox\voidb#x\penalty\#M\hskip\z#skip/\discretionary{-}{}{}\penalty\#M\hskip\z#skipwww.example.com
or
http:/\penalty\exhyphenpenalty/\penalty\exhyphenpenaltywww.example.com
I'd like to use a general solution that works in both cases, where the editor of the documentation can still use normal ReST and doesn't have to worry about latex.
Any idea how to get classic slashes in URLs and breakable slashes everywhere else?
You have not really given data and source code and only asked for an idea, so I take the liberty of only sketching a solution in pseudo code:
Split the document into a list of strings at each position of a space using .split()
For each string, check whether it is an URL by comparing its left side to http:// (and maybe also ftp://, https:// or similar tags)
Do replacements, but only in strings which are no URLs
Recombine all strings including the spaces again, using a command such as " ".join(my_list)
One way to do it, might be to write a Transform subclass. And then use add transform in setup(app) to use it in every read.
I could use DefaultSubstitutions from transforms.py as template for my own class.

Loading data from YAML in ruby changing the encoding/byte structure of data?

I am trying to write a method to remove some blacklisted characters like bom characters using their UTF-8 values. I am successful to achieve this by creating a method in String class with the following logic,
def remove_blacklist_utf_chars
self.force_encoding("UTF-8").gsub!(config[:blacklist_utf_chars][:zero_width_space].force_encoding("UTF-8"), "")
self
end
Now to make it useful across the applications and reusable I create a config in a yml file. The yml structure is something like,
:blacklist_utf_chars:
:zero_width_space: '"\u{200b}"'
(Edit) Also as suggested by Drenmi this didn't work,
:blacklist_utf_chars:
:zero_width_space: \u{200b}
The problem I am facing is that the method remove_blacklist_utf_chars does not work when I load the utf-encoding of blacklist characters from yml file
But when I directly pass these in the method and not via the yml file the method works.
So basically
self.force_encoding("UTF-8").gsub!("\u{200b}".force_encoding("UTF-8"), "") -- works.
but,
self.force_encoding("UTF-8").gsub!(config[:blacklist_utf_chars][:zero_width_space].force_encoding("UTF-8"), "") -- doesn't work.
I printed the value of config[:blacklist_utf_chars][:zero_width_space] and its equal to "\u{200b}"
I got this idea by referring: https://stackoverflow.com/a/5011768/2362505.
Now I am not sure how what exactly is happening when the blacklist chars list is loaded via yml in ruby code.
EDIT 2:
On further investigation I observed that there is an extra \ getting added while reading the hash from the yaml.
So,
puts config[:blacklist_utf_chars][:zero_width_space].dump
prints:
"\\u{200b}"
But then if I just define the yaml as:
:blacklist_utf_chars:
:zero_width_space: 200b
and do,
ch = "\u{#{config[:blacklist_utf_chars][:zero_width_space]}}"
self.force_encoding("UTF-8").gsub!(ch.force_encoding("UTF-8"), "")
I get
/Users/harshsingh/dir/to/code/utils.rb:121: invalid Unicode escape (SyntaxError)
The "\u{200b}" syntax is used for escaping Unicode characters in Ruby source code. It won’t work inside Yaml.
The equivalent syntax for a Yaml document is the similar "\u200b" (which also happens to be valid in Ruby). Note the lack of braces ({}), and also the double quotes are required, otherwise it will be parsed as literal \u200b.
So your Yaml file should look like this:
:blacklist_utf_chars:
:zero_width_space: "\u200b"
If you puts the value, and get the output "\u{200b}", it means the quotes are included in your string. I.e., you're actually calling:
self.force_encoding("UTF-8").gsub!('"\u{200b}"'.config[:blacklist_utf_chars][:zero_width_space].force_encoding("UTF-8"), "")
Try changing your YAML file to:
:blacklist_utf_chars:
:zero_width_space: \u{200b}

Joomla INI translation

I need to translate in my ini file a word that has a "()" or an "/" sign but it seems to brake when I do it.
eg.
sometext(text)="otherLanguagetext(text)" <-- this causes an error in the ini file an brakes all translations.
sometext/text = "someOthertext/text" <-- Broken also
having spaces work correctly:
Some text="Some text1" <--Works
The fact is that the original language is database generated and doesn't have any translation tag or something like joomla translation tag.
I just type the word I want to translate in this way.
I searched for an ini editor that might fix this out automatically (e.g place '/' or something ) but I had no luck on this.
Your example key's are invalid. INI files by definition can not have any of these characters: ?{}|&~![()^" in the keys.
Note: There are reserved words which must not be used as keys for ini
files. These include: null, yes, no, true, false, on, off, none.
Values null, off, no and false result in "". Values on, yes and true
result in "1". Characters ?{}|&~![()^" must not be used anywhere in
the key and have a special meaning in the value.
— http://www.php.net/manual/en/function.parse-ini-string.php
Joomla language files also have their own specification, which if not followed will cause an error when Joomla loads and parses the language file.
In INI files and Joomla language files the value also has special interpretations for specific characters and requires escaping for the use of some characters like double quotes etc.
Finally, Joomla has language overrides that allow the end user to override any string set by the core software or third party extensions which also affect the way keys are translated.
Try to use backslash before those symbols like this:
"otherLanguagetext\(text\)"
"someOthertext\/text"
P.S. you cannot use ANY special symbols in your constants! Try to name them something like this:
OTHER_LANGUAGE_TEXT
SOME_OTHER_TEXT
Try this,
SOME_TEXT = "otherLanguagetext(text)"
SOME_OTHER_TEXT = "someOthertext/text"
Hope it works

Resources