Multilanguage Content in Rails - mongodb

I'm about to start a new Project and need some advise.
For example, if i have a Model named "Page" that has "Posts" - how can i store more than one language when i create a new post and show only posts in a language when i click a - let's say - flag-icon at the top.
I have read a lot about l18n but as i understood - this is the way if i want to translate static messages like errors etc. ?
Hope somebody could explain a given strategy to to this in a clean way.
Thanks!

Like you said, localization and internationalization (abbreviated l10n and i18n, respectively) typically refer to the localization of the software product itself, rather than the content.
There are different strategies on how to manage content in multiple languages, and it does depend a lot on what you want to achieve. Suppose you operate a multilingual blog. However, some content is not relevant to an international audience, so you don't want to supply an English version (assuming your not a native English speaker, but I guess the point is clear).
Now it seems to make sense to simply not display that blog post in the English version of the blog. Hence, I'd suggest
Post {
"_id" : ObjectId('...'),
"PostGroupId: ObjectId('...'),
"Title" : "A Blog Post Title",
"Text" : "<h1>Lorem ipsum</h1> lots of text",
"Language" : "en",
"Published" : // and so on...
}
You can now easily query for all or specific posts in a given language: db.Posts.find({"language" : "en"}).sort({"Published" : -1});
Depending on your needs, you might want to add a grouping object for the posts to associate translations of posts to each other explicitly, using denormalized data:
PostGroup
{
"_id" : ObjectId('...'),
// ...
"Posts" : [{"lang" : "en", "id" : ObjectId('...')},
{"lang" : "de", "id" : ObjectId('...')} ]
// -- or simpler --
"AvailableLanguages" : ["en", "it", "fr"]
}

Related

how to get schema.org multiple keys for award category

I am trying to create a schema.org in ld+json and I have all the data working so far.
I am trying to create an array for the award field for a person so I can list multiple awards.
If I do "award" : "some award" as a solo item it works. But I am having trouble creating multiple awards.
I have tried
"award": [
{
"#type" : "award",
"name" : "award name"
}
]
But I get a validation error that award is not a known valid target type for the award property.
I have checked out schema.org and tried looking it up online, but have not found anything helpful.
Has anyone had any experience with getting this to work?
according to award's docs:
Values expected to be one of these types
Text
so, there's no #type, just plain text, so you can try listing awards as strings in an array:
{
"#context": "https://schema.org",
"#type": "Person",
"award": ["Award", "Another award", "And another one"]
}

Finding how to populate a field in Powershell with JiraPS

So, i'm using JiraPS to create some tickets and so far i've been able to work out through trial and error how to populate certain standard and custom fields.
I'm now wanting to create a ticket and link to other tickets. I'm looking to use a standard field called "Linked Issues"
Linked Issues Screen Shot
I've exported all the Jira fields and think this is one of these fields:
ID : issuelinks
Searchable : True
Schema : #{type=array; items=issuelinks; system=issuelinks}
Name : Linked Issues
Custom : False
Navigable : True
Orderable : True
ClauseNames :
and possibly "subtasks" for the issues field:
ID : subtasks
Searchable : False
Schema : #{type=array; items=issuelinks; system=subtasks}
Name : Sub-Tasks
Custom : False
Navigable : True
Orderable : False
ClauseNames : subtasks
I only think this as "items" match issuelinks.
I note that these are array records and have tried to no avail to give them a value when creating a ticket.
I get these errors:
Invoke-JiraMethod: subtasks -------- Field 'subtasks' cannot be set. It is not on the appropriate screen, or unknown.
nvoke-JiraMethod: issuelinks ---------- Field does not support update 'issuelinks'
If anyone has any ideas if I'm on the right track or way off!
Thanks
I've managed to work it out. I was thinking about it the wrong way, what I've done now is link the ticket to the parent, rather than trying to attach the child. Hope that makes sense...
I've used Add-JiraIssueLink on the child ticket(s) to link to the parent.

RKI_COVID19/FeatureServer - how to use that?

I am looking for a rest way to get more information out of a COVID19 map.
I noticed that arcgis provides plenty of topics and tutorials for developers.
I just don't know which tutorials are helping me to understand the FeatureServer.
I had two questions, can I query the below table with the rest api?
Like finding out what fields are in it, and what data.
If I have access to a serviceItemId - can I do anything useful with it?
"tables" : [
{
"id" : 0,
"name" : "RKI_COVID19",
"parentLayerId" : -1,
"defaultVisibility" : true,
"subLayerIds" : null,
"minScale" : 0,
"maxScale" : 0
}
]
Now I know how the query works.
https://developers.arcgis.com/rest/services-reference/query-related-records-feature-service-.htm
I found answers to what I was looking for.
Try this to access all data (query=1=1) in formatted son (pjson):
https://services7.arcgis.com/mOBPykOjAyBO2ZKk/arcgis/rest/services/RKI_COVID19/FeatureServer/0/query?where=1%3D1&outFields=*&f=pjson
Or have a look at this notebook that implements the data retrieval from there:
https://github.com/starschema/COVID-19-data/blob/master/notebooks/RKI_GER_COVID19_DASHBOARD.ipynb

Find and Delete documents in MongoDB using a Windows GUI tool

Okay, I'm a SQL Server based DBA, but there's a biz-critical app that uses MongoDB as a core component, and the problem is that it's grown too large. (The "large-ness" isn't critical yet, I'm trying to be proactive!)
Specifically, it has a "message log" collection which is over 400 GB, where the date-stamp is actually stored as a 2-element array [Int64, Int32], the 0th element being some measure of time (and the 1th element is just always '0').
So for example, a document:
{
"_id" : ObjectId("55ef63618c782e0afcf346cf"),
"CertNumber" : null,
"MachineName" : "WORKERBEE1",
"DateTime" : [
NumberLong(635773487051900000),
0
],
"Message" : "Waited 00:00:30.0013381 to get queue lock: Specs to verify",
"ScopeStart" : false
}
And just because 2 is better than 1, another example document:
{
"_id" : ObjectId("55ef63618c782e0afcf323be"),
"CertNumber" : null,
"MachineName" : "WORKERBEE2",
"DateTime" : [
NumberLong(635773487056430453),
0
],
"Message" : "Waited 00:00:30.0012345 to get queue lock: Specs to verify",
"ScopeStart" : false
}
I need to figure out two things:
What the heck does that "DateTime" really mean? It's not Unix Epoch time (seconds nor milliseconds); and even if I strip off the trailing 0's, it represents (in millis) 6/20/2171, so, unless we're building a time machine here, it makes no sense. If I strip off the last 6 digits, it means 2/23/1990, but even that doesn't seem likely, as this application has only existed since the early 2000's. (AFAIK)
Assuming we figure out #1, can we use some kind of command to remove (delete) all documents in the collection that are older than, say, 1/1/2016?
Again, I'm a SQL guy, so try to explain using analogs in that vein, e.g. "this is like your WHERE clause" and such.
PS: Yes, I read thru questions such as Find objects between two dates MongoDB and How do I convert a property in MongoDB from text to date type? , but so far nothing has jumped out at me.

Is there any way to force a schema to be respected?

First, I'd like to say that I really love NoSQL & MongoDB but I've got some major concerns with its schema-less aspect.
Let's say I have 2 tables. Employees and Movies.
And... I have a very stupid data layer / framework that sometimes like to save objects in the wrong tables.
So one day, a Movie gets saved in the Employees table. Like this:
> use mongoTests;
switched to db mongoTests
> db.employees.insert({ name : "Max Power", sex : "Male" });
> db.employees.find();
{ "_id" : ObjectId("4fb25ce6420141116081ae57"), "name" : "Max Power", "sex" : "Male" }
> db.employees.insert({ title : "Fight Club", actors : [{ name : "Brad Pitt" }, { name : "Edward Norton" }]});
> db.employees.find();
{ "_id" : ObjectId("4fb25ce6420141116081ae57"), "name" : "Max Power", "sex" : "Male" }
{ "_id" : ObjectId("4fb25db834a31eb59101235b"), "title" : "Fight Club", "actors" : [ { "name" : "Brad Pitt" }, { "name" : "Edward Norton" } ] }
This is VERY wrong.
Let's switch the context, think about Movies, and CreditCards (for whatever reason, in this context credit cards would be stored in clear text inside the DB). This is SUPER WRONG?
The code would probably explode because it's trying to use an object
structure and receives another totally unknown structure.
Even worst, the code actually works and the webstore visitors
actually see credit cards information in the "Rent a movie" list.
Is there anything, built-in that would prevent such threat to ever happen? Like some way to "force" a schema to be respected for only some tables?
Or is there any way to force MongoDB to make a schema mandatory? (Can't create new fields in a table, etc)
EDIT: For those who thinks I'm trolling, I'm really not, this is an important question for me and my team because this is a big decision whether or not we're going to use NoSQL.
Thanks and have a nice day.
The schema-less aspect is one of the major positives.
A DB with a schema doesn't fully remove this kind of issue - e.g. there could be a bug in a system that uses a RDBMS that puts the wrong data in the wrong field/table.
IMHO, the bigger concern would be, how did that kind of bug make it through dev, testing and out into production?!
Having said that, you could set up a process that checks the "schema" of documents within a collection (e.g. look at newly added documents, check whether they have fields you would expect to see in there) - then flag up for investigation. There is such a tool (node.js) here (I think, I've never used it):
http://dhendo.github.com/node-mongodb-schema-validator/
Edit:
For those finding this question in future, so the link in my comment doesn't go overlooked, there's a jira item for this kind of thing here:
http://jira.mongodb.org/browse/SERVER-3536