We are using a custom json format for our i18n resources that contain comments for the translation bureau, so they understand better the context of the strings to translate:
Example en.json:
{
"headerbar": {
"search": {
"placeholder": {
"value": "Enter your search here...",
"comment": "This string will be shown in the search input if empty. Truncated after 100 characters."
}
},
"welcome": {
"heading": {
"value": "Welcome, {{name}}!",
"comment": "This string should not be longer than 50 characters."
}
}
}
How can I configure i18next (or react-i18next) such that the translation is always retrieved from the value property? Without having to use {returnObjects} in every t().
t('headerbar.search.placeholder') // === 'Enter your search here...'
t('welcome.heading', {name: 'Bob'}) // === 'Welcome, Bob!'
I also have this requirement, but it appears i18next does not have the capability to define comments or descriptions, because 1) the API doesn't have a way to define those, and 2) the most popular extractor, i18next-parser, doesn't support generating files with comments included.
Alternatively, you could consider Format.JS which has this capability:
https://formatjs.io/docs/getting-started/message-declaration
Related
I'm using express-validator version 6.14.1
My body object looks like this:
{
"sections":[
{
"data":{
"navigation":[
{
"name":"Facebook",
"href":""
},
{
"name":"Google To",
"href":"https://google.com"
}
]
},
"section_id":"123",
"key":"abcdefgh"
}
],
"key":"abcdefgh",
"title":"New Demo",
"description":"New Description",
"status":"done"
}
I need to check whether the href values inside navigation array are valid.
I tried the below solution, but it doesn't work. It always skips the validation and returns true.
check("sections.*.data.navigation.*.href")
.isURL()
.withMessage("Not a valid Link"),
What is the right approach to solve this?
We have a json schema that includes a field, for which we want to control the value via the schema (rather than having the user specify the value).
We can set a default value - but this is simply overwritten by the formData that the user parses.
Is there a way to "lock" the field value to the default value provided in the schema, ensuring that the formData is updated with the schema-specified value?
{
"meta": {
"title": "SCHEMA REVISION",
"type": "object",
"properties": {
"rev": {
"title": "We want to lock the below default value via the schema",
"type": "string",
"default": "10.00"
}
}
}
}
Sorry, you cannot do this using the schema alone. It's not designed to be used for forms, so it doesn't have that functionality.
It sounds like you want a read-only field. The documentation for react JSON Schema form supports this: https://github.com/mozilla-services/react-jsonschema-form#read-only-fields
The ui:readonly uiSchema directive will mark all child widgets from a
given field as read-only.
Note: the uiSchema is in addition to your JSON Schema.
When using Google Sheets Api to create automated reports I've found that any string that ends with ".com" automatically gets formatted as a link (I've attached a picture). I'd like to remove this formatting via the api, Is this possible?
Two examples of the autolink formatting
You can change the hyperlink format to the plain text format using "hyperlinkDisplayType". The endpoint and request body are as follows. As a sample, the request body removes the hyperlink format of cells "A1:A3". I thought that from the image of your question, repeatCell might be suitable for your situation.
Endpoint :
POST https://sheets.googleapis.com/v4/spreadsheets/### spreadsheet ID ###:batchUpdate
Request body :
{
"requests":
[
{
"repeatCell":
{
"cell":
{
"userEnteredFormat":
{
"hyperlinkDisplayType": "PLAIN_TEXT"
}
},
"fields": "userEnteredFormat.hyperlinkDisplayType",
"range":
{
"sheetId": sheetId,
"startRowIndex": 0,
"endRowIndex": 3,
"startColumnIndex": 0,
"endColumnIndex": 1
}
}
}
]
}
Note :
This answer supposes that you can use Sheets API.
Reference :
HyperlinkDisplayType
RepeatCellRequest
If I misunderstand your question, I'm sorry.
I am indexing some text with stopwords enabled and I would like to search against these using "match phrase" query without slop, but it looks like stopwords are still taking in account for terms positions.
Building index:
PUT /fr_articles
{
"settings": {
"analysis": {
"analyzer": {
"stop": {
"type": "standard",
"stopwords" : ["the"]
}
}
}
},
"mappings": {
"test": {
"properties": {
"title": {
"type": "string",
"analyzer": "stop"
}
}
}
}
}
Add a document:
POST /fr_articles/test/1
{
"title" : "Tom the king of Toulon!"
}
Search:
POST /fr_articles/_search
{
"fields": [
"title"
],
"explain": true,
"query": {
"match": {
"title": {
"query": "tom king",
"type" : "phrase"
}
}
}
}
Nothing found ;-(
Is there a way to fix it? Or maybe with multiple span queries, but I want the term near each other.
Thanks you,
The position increments cause this issue, yes. While the stop word may be gone and not searchable, it still doesn't shove the two words up next to each other, so the query "tom the king" finds neither "tom king" nor "such that tom will not be their king".
Often, when you remove something in analysis with a filter, it's not quite as if it was never there. The intent of StopFilter, in particular, is to remove search hits resulting from uninteresting terms. It is not to change the structure of the document or a sentence.
You used to be able to disable position increments, on StopFilter, but that option has been removed, as of Lucene 4.4.
Okay, forget that CharFilter tomfoolery. Ugly hack, don't do that.
To query without using position increments, you need to configure that in your query parser, not in the analysis. This can be done in elasticsearch, with a Query String Query, with enable_position_increments set to false.
Something like:
{
"query_string" : {
"default_field" : "title",
"query" : "\"tom king\""
"enable_position_increments" : false
}
}
As a point of interest, similar solution in raw Lucene, by setting QueryParser.setEnablePositionIncrements.
There was an option enable_position_increments: false that you could set e.g. in a stop filter, but it has been deprecated since Lucene 4.4
This is the related Lucene issue: https://issues.apache.org/jira/browse/LUCENE-4065
In other words, the best way to go at the moment is probably to use the slop option, until the Lucene issue is fixed
I want to check whether the user shared my content in google plus or not, I tried onendinteraction callback but user may click close button instead of share button so i need to detect user originally shared content or not?
Just noticed this linked question. I answered it on another post but here it is again -
According to Google Developer page for their web platform, it seems you can tap into the current users activities list using a javascript code similar to -
var request = gapi.client.plus.activities.list({
'userId' : 'me',
'collection' : 'public'
});
request.execute(function(resp) {
var numItems = resp.items.length;
for (var i = 0; i < numItems; i++) {
console.log('ID: ' + resp.items[i].id + ' Content: ' +
resp.items[i].object.content);
}
});
The online tool to generate and test the query end point is there on the Developer Page
Generate and append a custom query string to the end of the link your user is sharing, the JSON returned from the end point can be parsed to check if that particular link has been shared on the users activity stream.
The JSON returned looks like this -
{
"items": [
{
"title": "",
"published": "2015-06-12T16:39:11.176Z",
"url": "https://plus.google.com/+UserID/posts/PostID",
"object": {
"content": "",
"attachments": [
{
"objectType": "article",
"url": "http://www.example.com"
}
]
}
}
]
}
If the link with the custom query is there in the attachments section of one of the returned items,Voila! Its been shared.