I might be getting the wrong end of the stick, but I am trying to pluralise a value with i18next package but also add in a static variable name:
Here is the json:
{
"likes": {
"pluralise_zero": "~~{{name}}~~ **liked** your post",
"pluralise_one": "~~{{name}}~~ and {{count}} other **liked** your post",
"pluralise_other": "~~{{name}}~~ and {{count}} others **liked** your post"
}
}
And I am calling it like so:
t('likes.pluralise', name, count)
The like count should be pluralised, but the {{name}} should not be. What I'm finding is that when I run this code, {{name}} is also pluralised like which looks something like:
{
count: 4
name0: "persons name"
name1: "another name"
name2: "someone else"
}
Is there a way to achieve what I need?
Related
Hello everyone last 16 hours I`m trying to implement this search with mongoose, and unfortunately whatever I try didn't work.
Hope someone here will be able to help me.
So I have schema
const propertySchema = new mongoose.Schema({
city:{
type:String
},
district:{
type:String
},
address:{
type:String
}
});
const Property = mongoose.model('property',propertySchema);
exports.module = Property
And this is my collection (demo) data
{
"city":"Prague",
"district":"district 1 ",
"address":address 1"
},
{
"city":"Prague",
"district":"district 1 ",
"address":address 1"
},
{
"city":"Ostrava",
"district":"district 2 ",
"address":address 2"
},
{
"city":"Ostrava",
"district":"district 2",
"address":address 2"
},
{
"city":"Brno",
"district":"district 3",
"address":address 1" //Let`s pretend somehow this address in Bruno exists in Prague too
},
What I want now is when I write in search "Prague" to get result
Prague
Also when I write for example in search "address 1" to get result
address 1,district 1 , Prague
address 1,district 3 , Brno
I should look similar like https://www.zillow.com search
So far I came up with a lot of idea and this is last (that didn`t work but still I want to share it with you maybe with some modification can make this )
const all = await Property.find({$and:[{city:{$regex: req.body.tag, $options: 'i'}},{address:{$regex: req.body.tag, $options: 'i'}},{district:{$regex: req.body.tag, $options: 'i'}}]})
In this type of scenario, where you want to match search input to any field you have to put $or aggregation instead of $and. Because you want to match input to be either city or district or address.
I am making a call to my firestore like so:
firestore.collection('profiledata').doc(userID).get().then(doc => console.log(doc.data()))}
the data is being logged as it should be where I am saying console.log in the line above... It is returning data like so in my console:
{ "lastname": "xx", "firstname": "xxx", "companyname": "xxxx" }
what is the best way to output this data to my screen? I am quite new to react and am trying to learn! What I have so far is this:
render(){
return(
<div className='profile'>
<h1>User</h1>
{
<div>
<p>
First Name
Last Name
Company Name
</p>
</div>
)
})
}
</div>
Obviously this won't work, and those names last name, first name and company name are all just fillers, but how do I output this data to the screen? Any ideas?
I am passing the following payload through my AWS lambda:
{
from: 'Someone <example#email.here>',
cc: 'Chris <example#email.here>',
to: 'example#email.here',
template: 'payment-request',
'v:name': 'Client name',
'v:lawyerName': 'Chris',
'v:hoursBooked': '{"name":"1 hours","price":"£200","url":"https://www.example.com/booking","value":1,"selected":true,"type":"hour"}',
'v:workTypes': '[ { name: "something 1" }, { name: "something 2" } ]'
}
In the actual template I am using handlebars as follows:
{{name}} // Renders "Client name"
{{#each workTypes}}
{{this.name}} // Doesn't render anything
{{/each}}
or even accessing an object like:
{{hoursBooked.name}} // Doesn't render anything
{{hoursBooked.price}} // Doesn't render anything
In other words, strings seems to be fine but handlebars 3.0 specifically in mailgun templates doesnt' seem to render object's property values or arrays.
Any help would be greatly appreciated.
The key is:
JSON.stringify
Because few months ago i implemented this code (picture below, coming from mailgun.com inside template option menu) and doesn't worked and instead used like you did, and worked for a while and then it just stopped worked.
'v:workTypes': '[ { name: "something 1" }, { name: "something 2" } ]'
Now my code work just fine
var data = {
//Specify email data
from: from_who,
//The email to contact
to: mail,
//Subject and text data
subject: 'Mailing List',
template: "main_template",
'h:X-Mailgun-Variables': ''
}
var workTypes = [ { name: "something 1" }, { name: "something 2" } ];
data['h:X-Mailgun-Variables'] = JSON.stringify({
name: 'Client Name',
workTypes
});
Just solved my own problem:
apparently we need to use an undocumented hidden and not deductible parameter:
h:X-Mailgun-Variables in the payload we send
We also need to put on our wizardry hat 🧙🏻♂️ to debug their own api: if you follow their example in the official website you will never get anywhere in node.js as it will error out (source.on). Make sure you stringify instead as follows:
'h:X-Mailgun-Variables': JSON.stringify({
name: 'Client name',
lawyerName: lawyerName,
hoursBooked: hoursBooked,
workTypes: workTypes
})
bonus: if your account is from eu, well best of luck the normal implementation won't work! But I got you covered...when passing the parameters to the mailgun.client({}) constructor, add in the following:
mailgun.client({
username: 'api',
key: process.env.yourkey,
url: 'https://api.eu.mailgun.net' // This
)}
// I can access the AccountSite property from other handlers/functions in the file using loops except in that function. I can get all Other properties using loops in the function except that one.
// I have tried My code in visual studio using console.log for debugging instead of Say(in Alexa) and I can have access to the property with the exact code except for that change.
const Data = [{
AccountName: "Jhon Doe ",
Phone: "353262",
Website: "something.com",
AccountSite: "Random Name",
Description: "Random Description",
AccountOwner: "Jhondoe#yahoo.com"
},
{
AccountName: "Jane Doe ",
Phone: "353223462",
Website: "something2.com",
AccountSite: "Random Name2",
Description: "Random Description2",
AccountOwner: "Janedoe#yahoo.com"
},{
AccountName: "Susan Doe ",
Phone: "353232462",
Website: "something3.com",
AccountSite: "Random Name3",
Description: "Random Description3",
AccountOwner: "susandoe#yahoo.com"
},
];
const getAccounSite_Handler = {
//handler code
//handler code
//handler code
let say;
Data.map(pos => {
say= ` ${pos.AccountSite}`; //if I put pos.Propertyname it would give me the property for the last object in the array for the other propert name except accountsite
// Account site is accessible in this handler if I don't use a loop
//have tried for loop and map
//have a very similar code for another skill but it is working; it is accessing the properties
//end of the handler
}
When I run Alexa it says "There was a problem with the requested skill's response" when the handler is called
As I understood, you want to make Alexa, to read all AccountSites? The code you have written right now always reassigns say on each loop instance. If you want to build a list of values and store it in variable say your code should look like this:
let say = '';
Data.forEach(pos => {
say += `${pos.AccountSite} `;
});
I tested it using your data and got the result that say is equal to:
"Random Name Random Name2 Random Name3 "
Is this is the result you wanted?
I am iterating through an array of person objects using ng-repeat Say the array looks like this:
[{
"display_name": "John Smith",
"status": "part-time",
"bio": "I am a person. I do people stuff.",
}, {
"display_name": "Jane Doe",
"status": "full-time",
"bio": "I am yet another person.",
}, ...]
Meanwhile, I have another number_list object that looks like this (note the uppercase):
{
"JOHN SMITH": 12,
"JANE DOE": 34,
...
}
In the HTML, I am able to interpolate from each person object like so:
<p>
Person Name: {{ person.display_name }}
Person Bio: {{ person.bio }}
...
</p>
But I'd also like to interpolate from the second object, accessing the value where the key matches the person object I'm on, like so:
<p>
...
Person Number: {{ number_list['{{ person.display_name | uppercase }}'] }}
</p>
I am using the EMCAScript Bracket notation rather than the dot notation to specify the key, because of the spaces in the key names of number_list (e.g."JOHN SMITH") but I get nothing out of that interpolation.
I have confirmed that if I type in a name e.g. {{ number_list['JOHN SMITH'] }} that I am able to interpolate the value -- 12 in this example. This means the issue doesn't have to do with scope or anything like that as far as I can tell.
Nested interpolation with double curly braces ({{ }}) is not supported by the AngularJS framework. If you want to run more complex code, you should make it a controller method and call the method from your view.
<p ng-repeat="person in persons">
...
̶P̶e̶r̶s̶o̶n̶ ̶N̶u̶m̶b̶e̶r̶:̶ ̶{̶{̶ ̶n̶u̶m̶b̶e̶r̶_̶l̶i̶s̶t̶[̶'̶{̶{̶ ̶p̶e̶r̶s̶o̶n̶.̶d̶i̶s̶p̶l̶a̶y̶_̶n̶a̶m̶e̶ ̶|̶ ̶u̶p̶p̶e̶r̶c̶a̶s̶e̶ ̶}̶}̶'̶]̶ ̶}̶}̶
Person Number: {{ ::personNumber(person.display_name) }}
</p>
$scope.personNumber = function(name) {
return $scope.number_list[name.toUpperCase()];
};
You can also use filter to personNumber for an object:
app.controller("ctrl", function($scope){
$scope.persons = [...];
$scope.number_list = [...];
})
app.filter("personNumber", function(){
return function(array, name){
return array[name.toUpperCase()];
}
})
<p ng-repeat="person in persons">
...
Person Number: {{person.display_name | personNumber: number_list}}
</p>