How to escape single curly brace in xi18n Angular5 localization - kendo-ui

I have a kendo-dropdown list in which I want to localize the default text. Is there any way to escape the single curly brace required for [defaultItem]?
Already Tried [defaultItem]="{{'{ text: 'Product Line', value: null }'}}" gives Parser Error: Got interpolation ({{}})
home.component.html
<kendo-dropdownlist id="ddlProductLine" i18n-[defaultItem]="##productlinedefaultitem" [defaultItem]="{ text: 'Product Line', value: null }" [data]="productLines" textField="text"
valueField="value" [valuePrimitive]="true" [(ngModel)]="selectedProductLineId" class="gprListFacets"
(selectionChange)="getBrandsFacet($event)">
</kendo-dropdownlist>
messages.en.xlf
<trans-unit id="productlinedefaultitem" datatype="html">
<source>{ text: 'Product Line', value: null }</source>
<target>{ text: 'Product Line', value: null }</target>
</trans-unit>
Angular i18n should identify kendo-dropdownlist [defaultItem] and pick a match from translation .xlf file.

Related

Ruby array of countries stripe connect accepts?

Is there somewhere I can get this list of countries as a ruby array?
I'll need it for a form field e.g.
<%= f.label :country %><br>
<%= f.select :country, ['Australia', 'Austria', 'etc', 'etc'], required: true %>
I could type it up manually (which I'll probably do), but just wanted to check that I'm not reinventing the wheel (it may already exist somewhere)
Okay, so there it is. Note that Mexico's commented out
stripe_connect_countries = [
'Australia',
'Austria',
'Belgium',
'Bulgaria',
'Canada',
'Cyprus',
'Czech Republic',
'Denmark',
'Estonia',
'Finland',
'France',
'Germany',
'Greece',
'Hong Kong SAR China',
'Hungary',
'Ireland',
'Italy',
'Japan',
'Latvia',
'Lithuania',
'Luxembourg',
'Malta',
# 'Mexico',
'Netherlands',
'New Zealand',
'Norway',
'Poland',
'Portugal',
'Romania',
'Singapore',
'Slovakia',
'Slovenia',
'Spain',
'Sweden',
'Switzerland',
'United Kingdom',
'United States'
]
Also note, that the country argument to Stripe functions typically wants a two-character alphanumeric country code (such as 'US', 'EG', or 'GB'). Here is a full list of country codes
Since it turns out these countries are user-friendly, but Stripe functions require the 2 character codes, here's a useful function providing a hash mapping countries to codes (again, Mexico commented out)
def stripe_connect_countries
{'Australia': 'AU',
'Austria': 'AT',
'Belgium': 'BE',
'Bulgaria': 'BG',
'Canada': 'CA',
'Cyprus': 'CY',
'Czech Republic': 'CZ',
'Denmark': 'DK',
'Estonia': 'EE',
'Finland': 'FI',
'France': 'FR',
'Germany': 'DE',
'Greece': 'GR',
'Hong Kong SAR China': 'HK',
'Hungary': 'HU',
'Ireland': 'IE',
'Italy': 'IT',
'Japan': 'JP',
'Latvia': 'LV',
'Lithuania': 'LT',
'Luxembourg': 'LU',
'Malta': 'MT',
# 'Mexico': 'MX',
'Netherlands': 'NL',
'New Zealand': 'NZ',
'Norway': 'NO',
'Poland': 'PL',
'Portugal': 'PT',
'Romania': 'RO',
'Singapore': 'SG',
'Slovakia': 'SK',
'Slovenia': 'SI',
'Spain': 'ES',
'Sweden': 'SE',
'Switzerland': 'CH',
'United Kingdom': 'GB',
'United States': 'US'
}
end

I need help about Title in sweetalert

I have an error (or nothing shows) on put a Text with quotes when I refer to inches ( " or ยดยด)
swal({
text: ' Product X 10" '
})
or
swal({
text: ' Product X 10' '
})
What might be the cause of this?

create an uneditable character in ruby textfield

I need to create an uneditable semicolon in Rails text field for a date.
For instance, the user can enter the hours and the minutes, while the semicolon already there and is not deletable.
<%= text_field_tag(:start_time, '', class: "timepicker four", size: 5,
maxlength: 5, placeholder: 'HH:MM', value:
#booking_item.start_time.strftime('%H') + ":"+
#booking_item.start_time.strftime('%M')) %>
Any solution for this in Ruby?
Thanks

Invalid indentation in Jade

I'm getting below error while trying to insert a script file in Jade
Can anyone please help?
form(method='post', action='/posts/add', enctype="mutilpart/form-data")
.form-group
label Title:
input.form-control(name='title', type='text')
.form-group
label Category:
select.form-control(name='category')
each category, i in categories
option(value='#{category.title}') #{category.title}
.form-group
label Body:
textarea.form-control(name='body', id='body')
.form-group
label Main Image:
input.form-control(name='mainimage', type='file')
.form-group
label Author:
select.form-control(anme='author')
option(value='Brad Traversy') Brad Traversy
option(value='John Doe') John Doe
input.btn.btn-defalut(name='submit',type='submit',value='Save')
script(src='/ckeditor/ckeditor.js')
script
| CKEDITOR.replace('body');
You have an syntax error here. Replace
script
CKEDITOR.replace('body');
by
script.
CKEDITOR.replace('body');

How do I turn this into, and then extract specific things from this array?

I have Facebook likes saved in a table (they're in a string) and do the following in the console to return the likes using the like method for the user model:
User.first.likes
=> "--- !seq:Koala::Facebook::GraphCollection \n- name: Rome Sweet Rome\n category:
Book\n id: \"136333439795671\"\n created_time: 2011-09-05T12:03:09+0000\n- name:
Drawn Together\n category: Tv show\n id: \"8694990902\"\n created_time:
2008-10-03T10:39:46+0000\n"
Below it is in YAML:
y User.first.likes
--- |
--- !seq:Koala::Facebook::GraphCollection
- name: Rome Sweet Rome
category: Book
id: "136333439795671"
created_time: 2011-09-05T12:03:09+0000
- name: Drawn Together
category: Tv show
id: "8694990902"
created_time: 2008-10-03T10:39:46+0000
=> nil
I want the end result to give me something like:
>> ["Rome sweet Rome", "Drawn Together"]
Split the string into separate lines, delimited by the \n character (or if it comes across as the string "\n", use double-quotes to delimit on that string)
like_elements = User.first.likes.split("\n") # <- String, not character, delimited version
=> ['id: "136333439795671"', 'created_time: 2011-09-05T12:03:09+0000", "- name: Drawn Together" ... etc.]
Then collect all elements that start with "- name: " into their own array:
name_elements = like_elements.select{|s| s.start_with?("- name: ")}
=> ["- name: Drawn Together", "- name: Rome sweet Rome"]
Then take each of the elements in name_elements and strip out the leading "- name: " text, and remove leading an trailing whitespace
names_of_likes_only = name_elements.collect{|n| n.gsub("- name: ", "").strip}
=> ["Drawn Together", "Rome sweet Rome"]

Resources