im having troubles using i18next with requireJs and Backbone. I have a folder named 'i18n' where all my resources are listed.
content of i18 folder:
resources-locale_en.js
resources-locale_es.js
resources-locale_fr.js
resources-locale_it.js
content of resources-locale_es.js
{
"john doe": "John Doe",
"my profile": "mi perfil",
"settings": "Ajustes",
"my tasks": "mis tareas",
"red": "rojo",
"orange": "orange"
}
On my require config.js:
.
.
.
//shim
i18n: {
deps: ['jquery']
}
.
.
.
var i18n = require('i18n');
i18n.init({
getAsync: false,
lang: 'en',
debug: true,
fallbackLng: false,
load:'unspecific',
resGetPath: "__ns_____lng__.js",
ns: {
namespaces: ['i18n/resources-locale'],
defaultNs: 'i18n/resources-locale'
}
}).done(function() {
new AppRouter({});
Backbone.history.start({
pushState: true
});
})
When DOM is loaded i run:
$("[data-i18n]").i18n();
but just list elements that content data-i18n, not transform anything
[ <span data-i18n="My Profile"></span>
, <span data-i18n="My Tasks"></span>
, <span data-i18n="Lock"></span>
, <span data-i18n="Log Out"></span>
, <span data-i18n="User Profile"></span>
, <span data-i18n="Dashboard"></span
]
What im doing wrong?
Related
{
"content": {
"en": {
"transfer_screen_amount_title": "Amount",
"demo_screen_welcome_title": "Welcome"
},
"bm": {
"transfer_screen_amount_title": "Jumlah",
"demo_screen_welcome_title": "Selamat Datang"
}
}
}
I reckon that in order to retrieve the value, we can set it like this t('content.en.transfer_screen_amount_title').
what if i want to use it like this instead t('transfer_screen_amount_title') ??
It depends on how your translations are loaded: https://www.i18next.com/how-to/add-or-load-translations
Here an example loading the resources on init:
https://github.com/i18next/react-i18next/blob/master/example/react-native/App.js#L20
So your code would look like this:
i18next
.use(languageDetector)
.use(initReactI18next)
.init({
fallbackLng: 'en',
debug: true,
defaultNS: 'content',
resources: {
en: {
content: {
transfer_screen_amount_title: 'Amount',
demo_screen_welcome_title: 'Welcome',
},
},
bm: {
content: {
transfer_screen_amount_title: 'Jumlah',
demo_screen_welcome_title: 'Selamat Datang',
},
},
},
});
// t('transfer_screen_amount_title')
Maybe read also: https://www.i18next.com/principles/namespaces
I have a problem for 2 days, I'm new in Symfony.
I'm using Symfony 3.4.
I create a Backend with Sonata for manage Entities and User.
My backend is ok, but now the twig templates are no longer working. I just have blank page.
Can you help me ? Thanks you in advance.
Here is my files :
composer.json
{
"name": "renicom.com/rcmanager1",
"license": "proprietary",
"type": "project",
"autoload": {
"psr-4": {
"AppBundle\\": "src/AppBundle",
"Application\\": "src/Application"
},
"classmap": [
"app/AppKernel.php",
"app/AppCache.php"
]
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
},
"files": [
"vendor/symfony/symfony/src/Symfony/Component/VarDumper/Resources/functions/dump.php"
]
},
"require": {
"php": ">=5.5.9",
"doctrine/doctrine-bundle": "^1.6",
"doctrine/doctrine-migrations-bundle": "^1.3",
"doctrine/orm": "^2.5",
"friendsofsymfony/rest-bundle": "^2.3",
"incenteev/composer-parameter-handler": "^2.0",
"knplabs/knp-markdown-bundle": "^1.7",
"knplabs/knp-paginator-bundle": "^2.8",
"nelmio/api-doc-bundle": "^3.2",
"sensio/distribution-bundle": "^5.0.19",
"sensio/framework-extra-bundle": "^5.0.0",
"sonata-project/admin-bundle": "^3.35",
"sonata-project/block-bundle": "^3.12",
"sonata-project/doctrine-orm-admin-bundle": "^3.6",
"sonata-project/easy-extends-bundle": "^2.5",
"sonata-project/google-authenticator": "^2.1",
"sonata-project/intl-bundle": "^2.5",
"sonata-project/media-bundle": "^3.13",
"sonata-project/user-bundle": "^4.2",
"symfony/monolog-bundle": "^3.1.0",
"symfony/polyfill-apcu": "^1.0",
"symfony/swiftmailer-bundle": "^2.6.4",
"symfony/symfony": "3.4.*",
"symfony/templating": "^4.1",
"twig/twig": "^1.0||^2.0"
},
"require-dev": {
"sensio/generator-bundle": "^3.0",
"symfony/phpunit-bridge": "^3.0"
},
"scripts": {
"symfony-scripts": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
],
"post-install-cmd": [
"#symfony-scripts"
],
"post-update-cmd": [
"#symfony-scripts"
]
},
"config": {
"sort-packages": true
},
"extra": {
"symfony-app-dir": "app",
"symfony-bin-dir": "bin",
"symfony-var-dir": "var",
"symfony-web-dir": "web",
"symfony-tests-dir": "tests",
"symfony-assets-install": "relative",
"incenteev-parameters": {
"file": "app/config/parameters.yml"
},
"branch-alias": null
}
}
AppKernel.php
$bundles = [
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new Symfony\Bundle\SecurityBundle\SecurityBundle(),
new Symfony\Bundle\TwigBundle\TwigBundle(),
new Symfony\Bundle\MonologBundle\MonologBundle(),
new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
new AppBundle\AppBundle(),
new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(),
new Sonata\CoreBundle\SonataCoreBundle(),
new Sonata\BlockBundle\SonataBlockBundle(),
new Knp\Bundle\MenuBundle\KnpMenuBundle(),
new Sonata\DoctrineORMAdminBundle\SonataDoctrineORMAdminBundle(),
new Sonata\AdminBundle\SonataAdminBundle(),
new Sonata\EasyExtendsBundle\SonataEasyExtendsBundle(),
new FOS\UserBundle\FOSUserBundle(),
new Sonata\UserBundle\SonataUserBundle('FOSUserBundle'),
new Application\Sonata\UserBundle\ApplicationSonataUserBundle(),
new Sonata\MediaBundle\SonataMediaBundle(),
new Application\Sonata\MediaBundle\ApplicationSonataMediaBundle(),
new JMS\SerializerBundle\JMSSerializerBundle(),
new Sonata\IntlBundle\SonataIntlBundle(),
new Knp\Bundle\MarkdownBundle\KnpMarkdownBundle(),
new Knp\Bundle\PaginatorBundle\KnpPaginatorBundle(),
];
The Controller
<?php
namespace AppBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
class AssetController extends Controller
{
/**
* #Route("/objets", name="asset_list_fr")
*/
public function listAction(Request $request, $slug = 'test'){
$asset_list = array();
if ($request->isMethod('GET')){
$params = $request->query;
$category = $this->getDoctrine()
->getRepository('AppBundle:Category');
$categoryP = $category->findOneBy(array('id' => 4));
$type = $this->getDoctrine()
->getRepository('AppBundle:Type');
$typeP = $type->findOneBy(array('id' => 30));
$sector = $this->getDoctrine()
->getRepository('AppBundle:Sector');
$sectorP = null;//$sector->findOneBy(array('id' => '3'));
$em = $this->getDoctrine()->getManager();
$asset_list = $em->getRepository('AppBundle:Asset')
->findBy(['category' => $categoryP]);
$assets = $this->get('knp_paginator')->paginate(
$asset_list, 1
);
}
return $this->render('asset/list.html.twig',
[
'slug' => $slug,
'assets' => $assets,
]);
}
}
My view asset/list.html.twig
{% extends 'base.html.twig' %}
{% block content %}
test
{% endblock %}
my config.yml
imports:
- { resource: parameters.yml }
- { resource: security.yml }
- { resource: services.yml }
parameters:
locale: en
framework:
translator: { fallbacks: ['%locale%'] }
secret: '%secret%'
router:
resource: '%kernel.project_dir%/app/config/routing.yml'
strict_requirements: ~
form: ~
csrf_protection: ~
validation: { enable_annotations: true }
default_locale: '%locale%'
trusted_hosts: ~
session:
handler_id: session.handler.native_file
save_path: '%kernel.project_dir%/var/sessions/%kernel.environment%'
fragments: ~
http_method_override: true
assets: ~
php_errors:
log: true
twig:
debug: '%kernel.debug%'
strict_variables: '%kernel.debug%'
doctrine:
dbal:
driver: pdo_mysql
host: '%database_host%'
port: '%database_port%'
dbname: '%database_name%'
user: '%database_user%'
password: '%database_password%'
charset: UTF8
types:
json: Sonata\Doctrine\Types\JsonType
orm:
auto_generate_proxy_classes: '%kernel.debug%'
entity_managers:
default:
auto_mapping: true
mappings:
ApplicationSonataUserBundle: ~
SonataUserBundle: ~
FOSUserBundle: ~
ApplicationSonataMediaBundle: ~
SonataMediaBundle: ~
swiftmailer:
transport: '%mailer_transport%'
host: '%mailer_host%'
username: '%mailer_user%'
password: '%mailer_password%'
spool: { type: memory }
fos_user:
db_driver: orm # can be orm or odm
firewall_name: main
user_class: Application\Sonata\UserBundle\Entity\User
group:
group_class: Application\Sonata\UserBundle\Entity\Group
group_manager: sonata.user.orm.group_manager
service:
mailer: fos_user.mailer.twig_swift
user_manager: sonata.user.orm.user_manager
from_email:
address: "test1#test.com" #"%mailer_user%"
sender_name: "test1#test.com" #"%mailer_user%"
sonata_user:
security_acl: true
manager_type: orm
class:
user: Application\Sonata\UserBundle\Entity\User
group: Application\Sonata\UserBundle\Entity\Group
admin:
user:
class: Sonata\UserBundle\Admin\Entity\UserAdmin
controller: SonataAdminBundle:CRUD
translation: SonataUserBundle
group:
class: Sonata\UserBundle\Admin\Entity\GroupAdmin
controller: SonataAdminBundle:CRUD
translation: SonataUserBundle
sonata_block:
default_contexts: [cms]
blocks:
sonata.user.block.account:
sonata.admin.block.admin_list:
contexts: [admin]
sonata_admin:
title_logo : /images/logo_remicom.png
title: Remicom Admin
sonata_media:
db_driver: doctrine_orm
default_context: default
contexts:
default:
providers:
- sonata.media.provider.dailymotion
- sonata.media.provider.youtube
- sonata.media.provider.image
- sonata.media.provider.file
- sonata.media.provider.vimeo
formats:
small: { width: 100, quality: 70}
big: { width: 500, quality: 70}
cdn:
server:
path: /uploads/media
filesystem:
local:
directory: "%kernel.root_dir%/../public/uploads/media"
create: false
providers:
image:
resizer: sonata.media.resizer.square
sonata_intl:
timezone:
default: Europe/Paris
knp_paginator:
page_range: 30
My routing.yml
app:
resource: '#AppBundle/Controller/'
type: annotation
admin_area:
resource: '#SonataAdminBundle/Resources/config/routing/sonata_admin.xml'
prefix: /admin
_sonata_admin:
resource: .
type: sonata_admin
prefix: /admin
fos_user:
resource: "#FOSUserBundle/Resources/config/routing/all.xml"
sonata_user_admin_security:
resource: '#SonataUserBundle/Resources/config/routing/admin_security.xml'
prefix: /admin
sonata_user_admin_resetting:
resource: '#SonataUserBundle/Resources/config/routing/admin_resetting.xml'
prefix: /admin/resetting
I add here 2 screen from the debug section.
The twig debug
The log
finaly I solve the problem. I start a new project and rebuild every part of my Symfony application in the same way, and all work well.
I don't know what was the problem. I certainly forget a little thing but I can't say what.
I'm trying to add youtube plugin plugin to Ckeditor4, anyway the plugins works fine but the icon in the toolbar is not shwoing at all.
This is the first part of code inside /youtube/plugin.js that define the youtube button on the toolbar:
CKEDITOR.plugins.add('youtube', {
lang: [ 'en', 'bg', 'pt', 'pt-br', 'ja', 'hu', 'it', 'fr', 'tr', 'ru', 'de', 'ar', 'nl', 'pl', 'vi', 'zh', 'el', 'he', 'es', 'nb', 'nn', 'fi', 'et', 'sk', 'cs', 'ko', 'eu' ],
init: function (editor) {
editor.addCommand('youtube', new CKEDITOR.dialogCommand('youtube', {
allowedContent: 'div{*}(*); iframe{*}[!width,!height,!src,!frameborder,!allowfullscreen]; object param[*]; a[*]; img[*]'
}));
editor.ui.addButton('Youtube', {
label : editor.lang.youtube.button,
toolbar : 'insert',
command : 'youtube',
icon : this.path + 'images/icon.png' //here console.log(this.path) return http://cdn.ckeditor.com/4.9.0/standard/plugins/youtube/
});
Normally when we add a new plugin such as the youtube plugin All we need is to change the path is to add these part of code into configuration:
CKEDITOR.plugins.addExternal('youtube', '../../node_modules/ckeditor-youtube-plugin/youtube/');
$rootScope.ckEditorOptions = { //ckEditorOptions represent my config variable
allowedContent : true,
extraPlugins: 'youtube',
toolbar_full: [
{name: 'youtube', items: ['Youtube']},
],
language: 'fr',
I noticed then, unfortunately the CKEDITOR.plugins.addExternal in the first line is not working right and because that line role is to define our path this.path who should not point to the CDN.
I'm sure that i'm missing something because when I try to edit manually the icon : this.path to icon : http://anylink.png the icon is showed.
Trying to display Milestone for each release, but when trying to create DataStore for Milestone getting error
Uncaught Rally.data.ModelFactory.getModel(): Could not find registered factory for type: milestone
below is my code any ideas or suggestions on this
_getMileStones: function(startDate, endDate, project_id) {
var startDateFilter = Ext.create('Rally.data.QueryFilter', {
property: 'TargetDate',
operator: '>',
value: startDate
});
startDateFilter = startDateFilter.and({
property: 'TargetDate',
operator: '<',
value: endDate
});
startDateFilter = startDateFilter.and({
property: 'TargetDate',
operator: '!=',
value: null
});
startDateFilter = startDateFilter.and({
property: 'TargetDate',
operator: '!=',
value: null
});
var filters = startDateFilter;
Ext.create('Rally.data.wsapi.Store',{
model: 'milestone',
autoLoad: true,
filters: filters,
context: {
project: project_id,
projectScopeDown: true,
projectScopeUp: false
},
fetch: ['Name','FormattedID','DisplayColor'],
listeners: {
load: function(store,records) {
console.log("records values", records);
}
}
}, this);
},
The current stable rc3 release candidate of AppSDK2 predates milestones. They are not available in rc3. When I use rc3 I get the same error you get. If I switch to "x", in the app's config file, and use rab build to rebuild the app, the error goes away:
{
"name": "myapp",
"className": "CustomApp",
"server": "https://rally1.rallydev.com",
"sdk": "x",
"javascript": [
"App.js"
],
"css": [
"app.css"
]
}
Generally it is not recommend using "x" because it is constantly changes. It is not a stable version. But as long as you know that, you may use "x". The AppSDK next release may not be too far in the future, and it will include support for Milestones.
UPDATE: AppSDK2.0 GA has not been announced yet, but it is expected to be released soon. If you use "sdk":"2.0" you get Milestone data.
"x" returns Milestones, but it is a head version that is subject to constant changes. 2.0rc3 does not have Milestones.
You may choose to use 2.0 even though it is not formally available yet.
This app example:
Ext.define('CustomApp', {
extend: 'Rally.app.App',
componentCls: 'app',
launch: function() {
Ext.create('Rally.data.wsapi.Store',{
model: 'milestone',
autoLoad: true,
fetch: ['Name'],
listeners: {
load: function(store,records) {
console.log("records values", records);
}
}
}, this);
}
});
Along with this config:
{
"name": "milestones",
"className": "CustomApp",
"server": "https://rally1.rallydev.com",
"sdk": "2.0",
"javascript": [
"App.js"
],
"css": [
"app.css"
]
}
will return milestone data:
Trying to create a filter for Angular.js
Controller.js sample snippet:
function TitleListCtrl($scope) {
$scope.titles = [
{ "name": "Foobar",
"editions":
[{"print": true,
"ebook": false,
"audio": false }]
},
{ "name": "FooBarBar",
"editions":
[{"print": false,
"ebook": false,
"audio": false }]
}
];}
Angular html:
<ul ng-controller="TitleListCtrl">
<li class="TitleList" ng-repeat="title in titles
| filter:isUpcoming
| orderBy:'date'">{{title.name}}</li>
</ul>
Now, I'm trying to return only those titles who have no active editions (no members of the edition array is set to true). Finding it hard to find examples online doing something like this...
$scope.isUpcoming = function(title) {
return title.editions[0] & title.editions[1] & title.editions[2]===false;
};
Instead of the above approach, I used data-ng-show:
<ul ng-controller="TitleListCtrl">
<li class="TitleList" data-ng-show="!(title.upcoming)"
ng-repeat="title in titles
| filter:query
| orderBy:'date'">{{title.name}}</li>
</ul>
And added a new pair "upcoming": true, for titles where needed.
function TitleListCtrl($scope) {
$scope.titles = [
{ "name": "Foobar",
"editions":
[{"print": true,
"ebook": false,
"audio": false }]
},
{ "name": "FooBarBar",
"editions":
[{"print": false,
"ebook": false,
"audio": false }],
"upcoming": true
}
];}
Please have a look at the plunker http://plnkr.co/edit/SkXnZhwic8KHWvj0JyFI?p=preview.
It implements a custom filter which filters out the long list to upcoming list and then renders the upcoming list