Change whole application language using tap-i18n package - meteor

As per this site
https://github.com/TAPevents/tap-i18n/blob/master/README.md#quickstart
i have started with demo using tap-i18n package and it works fine.
Now
I want Convert application language when selecting language from drop-down list.
For that i have created one meteor application.
in that i have putted on drop-down list filled with different languages.
Now ,
when i select any language from drop-down list it should change whole application language using tap-i18n package.
it is possible?
Thanks,

take a look to this example http://blog.digital-hosting.info/meteor-internationalisation/
header.html
<div class="dropdown">
<button class="btn btn-info" data-toggle="dropdown">Languages</button>
<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
<li>Francais</li>
<li>English</li>
<li>中文</li>
</ul>
</div>
header.coffee
Template.header.events = "click a.lang": (e) ->
lang = 'undefined'
$this = $(e.target)
lang = $this.data("lang")
TAPi18n.setLanguage lang
return

Related

Thymeleaf setting model field with th:field on button dropdown not working

I am trying to set the field on my model object using thymeleaf in a form.
setting th:field on the button is giving back all null properties. They are all formatted the same but this is the look:
<div class="dropdown">
<button th:field="*{product}" class="btn grey-dropdown dropdown-toggle" type="button"
data-toggle="dropdown">(Select)<span class="caret"></span>
</button>
<ul class="dropdown-menu filter-dropdown-items">
<li th:each="product : ${products}"><a><span
th:text="${product}" th:remove="tag"></span></a></li>
</ul>
</div>
Am I doing something wrong? The post comes back with null fields.
As far as I can tell, th:field only supports the following tags:
input
select
textarea
If you want to bind a button, I think you're going to have to do it manually. (th:field sets the name, id, and value attributes so it shouldn't be difficult to set them to the correct values.)

Add class to ian:accounts-ui-bootstrap-3 SELECT tag when rendered [Meteor JS + Blaze]

Meteor 1.6.1.1 is the latest version of my project. I am using package ian:accounts-ui-bootstrap-3 instead of accounts-ui. I have added a custom field as <select> in the code.
What I get on Screen is as below.
When I saw the HTML code, it is not adding class="form-control" to select tag.
below is the code when I inspect element on UI using Chrome.
<li id="login-dropdown-list" class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" aria-expanded="false">Sign in / Join <b class="caret"></b></a>
<div class="dropdown-menu">
<div class="select-dropdown">
<label>State</label><br>
<select id="login-state">
</select>
</div>
<button class="btn btn-primary col-xs-12 col-sm-12" id="login-buttons-password" type="button">
Create
</button>
<button id="back-to-login-link" class="btn btn-default col-xs-12 col-sm-12">Cancel</button>
</div>
</li>
All I want is to add class="form-control" to the select tag dynamically when component loads on screen and it must look like below;
I have tried below code, but it is not working;
Template.HomePage.onRendered(function () {
document.getElementById('login-state').classList.add('form-control');
});
Well, I tried one way to achieve this is by using Template event as below,
Template.HomePage.events({
'click #login-dropdown-list': function(event){
//document.getElementById('login-state').classList.add('form-control');
$('#login-state').addClass('form-control');
}
});
As you can see, the component gets loaded inside the li tag with id="login-dropdown-list". I simply loaded the class on click event. Even the commented code works fine.
Is this a good solution? please let me know if there much better answer to this? If it works I will definitely accept and upvote the answer.

How Do I Join Data From Two Collections Using Spacebars?

I have a template (tmpl1) which refers to a collection projectdetails, in the following code I can successfully show {{detailname}} what is based on the collectiondata projectdetails.detailname
But now I need to show also the Projectname which is in projects.name I do have the project._id saved in projectdetails.projectId
How can I now define a handelbar like {{projectName}} to display the project name.
I have tried to define this in projectdetails.js as helper but I was not successful. Can someone please add a code sniplet which explains how to define the handelbar and how to retrieve the data?
<template name="tmpl1">
<div id="example" class="panel">
<ol class="breadcrumb">
<li><i class="fa fa-home"></i> Start</li>
<li><i class="fa fa-cubes"></i> Projekte</li>
<li><i class="fa fa-cogs"></i> Details</li>
<li class="active">{{detailname}} {{projectName}}</li>
</ol>
</div>
You can just add a helper for projectName which joins the two collections.
The context of your template appears to be a "project detail" document, so inside of the projectName helper, this.projectId should be the id of the project document. Assuming the collection is called Projects and each project has a name field, the code should look something like this:
Template.tmpl1.helpers({
projectName: function() {
var project = Projects.findOne(this.projectId);
return project && project.name;
}
});

Creating a split-button-dropdown in asp.net MVC with Twitter Bootstrap

I am trying to create a split button dropdown using Bootstrap and ASP.NET MVC 5, but I cannot seem to render the correct markup. This is what I have so far...
<div class="btn-group">
#Html.ActionLink("Details", "Details", new { id = item.ClientTypeID }, new { #class = "btn btn-sm btn-primary" })
<a class="btn btn-sm dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>#Html.ActionLink("Edit", "Edit", new { id = item.ClientTypeID })</li>
<li>#Html.ActionLink("Delete", "Delete", new { id = item.ClientTypeID })</li>
</ul>
</div>
I have no doubt that this is my own fault, but can anybody please point out what I should actually have in my template. Instead of the required drop down, I am seeing the initial "Details" button, and I am seeing the drop down caret, but clicking on the caret does not show the additional items.
In case it makes a difference, I am using the default templates from VS2013 along with the Cosmo theme from Bootswatch. This is also being rendered in a table cell.
Thanks.
Make sure you have registered jQuery before bootstrap.min.js.
Debug the error using Developer Tools available in all modern browsers.
Chrome use Ctrl+J, IE use F12, FireFox use Shift+F2
Happy Coding..

How to Access Uploaded Files Using plone.formwidget.multifile

I have a custom Dexterity type that utilizes plone.formwidget.multifile.MultiFileFieldWidget:
class ITestimony(form.Schema):
...
form.widget(files=MultiFileFieldWidget)
files = schema.List(
title=_(u"Files"),
value_type=NamedFile()
)
Everything goes well as expected when editing the item:
Here is the relevant view template, that I try borrow from https://developer.plone.org/reference_manuals/external/plone.app.dexterity/advanced/files-and-images.html:
<fieldset tal:condition="context/files">
<legend>Attached Files</legend>
<ul>
<tal:files repeat="item context/files">
<li><a href=""
tal:attributes="href string:${context/absolute_url}/##download/files/${item/filename};"
tal:content="item/filename">Attached File</a></li>
</tal:files>
</ul>
</fieldset>
I want the attached files can be downloaded by clicking on the links. But I get error with my current template:
AttributeError: 'list' object has no attribute 'getSize'
How can I download my uploaded files?
Actually the answer is from http://josh.postach.io/multiple-file-upload-custom-dexterity-content-types-plone-5-02a
The following snippet works for me:
<fieldset tal:condition="context/files">
<legend>Attached Files</legend>
<ul>
<tal:files repeat="item context/files">
<li><a href=""
tal:attributes="href string:${context/absolute_url}/##edit/++widget++form.widgets.files/##download/${repeat/item/index}"
tal:content="item/filename">Attached File</a></li>
</tal:files>
</ul>
</fieldset>
Although using ##edit is wired here, hopefully we will have better version of plone.formwidget.multifile or related packages soon.
Some notes about how files are handled with Dexterity are here:
http://developer.plone.org/forms/files.html
Specifically, constructing download URLs:
http://developer.plone.org/forms/files.html#connstring-download-urls
(##download helper view)

Resources