symfony 1_4 factories i18n param source container yaml - internationalization

When I generate the translate container file (message.xml)
by using this command :
php symfony i18n:extract frontend en --auto-save
is it possible to replace the XML file by a YML file ?

You can't.
Symfony 1.x only rely on xliff file to handle internationalization. So you can't use a yml file for that.
All translations are stored in a catalogue. The i18n framework provides a lot of different strategies to store the translations. We will use the "XLIFF" format, which is a standard and the most flexible one. It is also the store used by the admin generator and most symfony plugins.
As you can see here, there is no function like sfMessageSource_Yml to handle i18n inside yaml file.
But you can handle translation in database. There are some plugins for that:
tmcI18nPlugin
mgI18nPlugin

Related

How to add prefix in URI while loading XQuery file using ml-gradle

I am using gradle 6.8 and MarkLogic version is 10.0-5.2,
My XQuery code is in directory \ml-gradle\src\main\common. When I run the command mlLoadModules to load XQuery into the modules database it loads with default URI /common/test.xqy.
I want to add some prefix to the URIs e.g. /rsc/common/test.xqy. How can I achieve that?
Note: I don't want to create an extra folder in my source for prefix "rsc".
It's not supported, though you could write a custom Gradle task to change the URI to whatever you like.
Why do you not want to create an "rsc" folder above "common"? I think other developers would find it much more intuitive that "rsc/common/test.xqy" becomes "/rsc/common/test.xqy" when loaded, rather than "common/test.xqy" becomes "rsc/common/test.xqy", which begs the question - where is "rsc" coming from? And then that developer would need to understand what property / custom code is adding that "rsc".

I am looking for code policy enforcement tool for xml and Python

I have projects that are developed with xml and python code mostly (Odoo modules). There is a bit of .po files for translation and csv fields for data.
I would like to enforce specific policies in xml files, for example:
No duplicate id attributes.
A specific attribute must be present if child elements contain a specific tags.
On python, I want to enforce rules like:
Look for SQL queries, and make sure that they use specific parameter methods to prevent SQL injection
Follow a specific naming convention
Some attributes are required in classes that inherit a specific class
I hope that the idea is clear.
Is there any open source solution for this? Preferably linked with github and checks on every commit!
I found a python package made specifically for this, pylint-odoo, here.
It can also be installed with pip install pylint-odoo.
An example .pylintrc config file can be found at the web OCA module, here. They also have another file named .pylintrc-mandatory.
There is even a warning for duplicate xml id attribute W7902.

Which library is used for setting validations in Codemirror Json Editor?

Which library is used for setting validations in Codemirror Json Editor ?
See on this page: https://codemirror.net/demo/lint.html
which uses amongst other serveral source also this: https://codemirror.net/addon/lint/json-lint.js
and when using the source-view you will find this:
// Depends on jsonlint.js from https://github.com/zaach/jsonlint
so this would be the answer: https://github.com/zaach/jsonlint
A JSON parser and validator with a CLI.
http://zaach.github.com/jsonlint/

Using php scripts on my views in Laravel 4

I am using the Laravel 4 framework, and I am trying to set up the Facebook authentication system. I have an authentication system I had set up on another site (not using a framework) that used a config.php and process_facebook.php file. I am trying to implement this config.php file into my views. So far, I am including the files in a folder called "includes", within my "app" folder. I am trying to use the following code to implement it:
$app = app();
include($app['path.app'].'/includes/config.php');
My question is, where in the view do I put this code? Do I have to use php tags? (I am using the blad functionality). Your help is appreciated.
Laravel is an MVC framework, the purpose is to organise your code and clean your views. So this shouldn't be in your view.
I think the best way should be :
Create a facebook.php file in the config folder wich contains all your facebook configuration (read http://laravel.com/docs/configuration)
Create a folder named services, helpers or includes (as you want) and put process_facebook.php inside (I bet it contains the methods to deal with facebook API).
Add two lines of configuration to include this new folder
Like that :
// composer.json
"autoload": {
"classmap": [
[...]
"app/services",
]
},
// start/global.php
ClassLoader::addDirectories(array(
[...]
app_path().'/services',
));
Then, you can use your facebook class or methods all over your app.
The route you are taking to include configuration files is not recommended, but it is possible. Please see information about Laravel Configuration Files.
You should be able to use the following in your view:
<?php include(app_path().'/includes/config.php'); ?>
As it is a configuration file, it would be better to use require() instead of include().
In addition, it would also be better to include the file in the necessary controller(s).

YAML Schema Validation?

Is there a schema validation language for YAML? I've googled but couldn't find anything useful.
Something like XSD format, using the language itself to describe the schema, would be the best choice in my case.
JSON Schema can be used with most YAML documents resulting in a more portable and better documented solution than Rx or Kwalify. JSON Schema is the only of the three for which I have been able to find editor support.
More information on using YAML and JSON Schema including tools and editor support is tracked on this page. At the time of writing, there is editor support in Visual Studio Code and a command-line based validation tool available via npm.
Full Disclosure: I authored the web site linked above to try to make the application of JSON Schema to YAML more discoverable. I also wrote an editor extension for VS Code that has since been superseded by the RedHat extension linked above.
Try Kwalify (Ruby and Java only), or Rx (many languages)
I wonder if it would make sense to reuse JSON schema for this. YAML can be easily converted to JSON without loosing any information (?), so in theory YAML could be validated by the same tool chain, allowing open source community to concentrate on one good schema tool chain. The schema itself could also be written in YAML and converted to JSON.
Good idea. Googled this up because I was looking for the same.
It's possible to convert YAML to XML in a defined manner (similarly to JSON <-> XML) and validate with a standard XML validator.
Depending on your platform, there are tools or snippets for that conversion: JavaScript (NPM), Ruby, Java (Jackson), Java (TestNG) (you'll need to see the source for what parameters it wants).
If done using an API, the error positions can even be mapped back to the original YAML file.
You can use this python ysd project to validate your yaml files. https://github.com/yonahd/ysd
Super simple to use
python yaml-validator/main.py -v yamls/example-values.yaml -r yamls/example-rules.yaml
Example rule file:
required: // field must exist and type must match
env: str
enabled: bool
replicas: int
optional: // if field exists type must match
disk: str
Example yaml file (helm values file):
network:
service:
port: 8060
enabled: true
image:
app: my-app:build
replicas: 1
env: dev
disk: local
If your project is in C++, you can also use the yaml-schema-cpp library. It allows to validate (and complete) the .yaml input files using schema files (YAML files with extension .schema) from your C++ code.

Resources