I am checking the Platform docs (https://ionicframework.com/docs/utilities/platform) for ionic 4, i see that the lang() function which was available in ionic 3 (https://ionicframework.com/docs/v3/api/platform/Platform/) is not implemented.
Is there any alternative for this? I am trying to migrate an ionic 3 project to 4 where i have the following code to detect the user's language
const browserLanguage = navigator.language || this.platform.lang();
Thanks in advance!
You can use the Globalization Plugin
this.globalization.getPreferredLanguage()
.then(res => console.log(res))
.catch(e => console.log(e));
Related
I am using Backpack for Laravel v4.1.10.
After the upgrade from v.4.0 the filter collapse button in small screens stopped working.
On button click my console error is:
TypeError: can't convert n to string
on the following line of bundle.js (line 9920 expanded):
if (!i && o.toggle && /show|hide/.test(n) && (o.toggle = !1), i || (i = new t(this, o), r.data('bs.collapse', i)), 'string' == typeof n)
Other info: php v7.3.9, Laravel v.7.16.1
Apparently it is not a framework bug as it is not existent in the live demo of backpack.
Any feedback to troubleshoot the issue is very welcome.
I fixed the issue by replacing the bundle.js file with the one provided in the official repository of backpack. Maybe it had not been updated at the version upgrade although I cannot fathom a reason for that.
Hi guys I am working on this live project where I want to store the quantity/count values (1,2,3....) locally. I just need a little guidance with the code. I am learning ionic. This is my ts files code snippet.
this.cartArr.push(items);
this.dataPrint = this.cartArr;
let item =this.dataPrint;
let selected = {};
for(let obj of item){
if(selected[obj.ITEMID]){
selected[obj.ITEMID].count++;
}else{
selected[obj.ITEMID] = {...obj,count: 1};
}
}
this.selectedItems = Object.keys(selected).map(key => selected[key])
console.log('items: ',this.selectedItems);
this.total = this.selectedItems.reduce((a, b) => a + (b.count * b.RATE), 0);
this.storage.set('cartItems',this.selectedItems);
To store data locally we generally prefer Local DB and for that Ionic have also good and easy plugin to store data locally in sqlite.
Plugin to store data locally in Sqlite:
Storage
How to use?
Follow the instruction from above link to add plugin into ur app.
$ionic cordova plugin add cordova-sqlite-storage
$npm install --save #ionic/storage
Set Data:
//set a key/value
this.storage.set('key', 'Value');
Get Data:
//get a key/value pair
this.storage.get('age').then((val) => {
console.log('Your age is', val);
});
Hope this will help you to store your data in local DB.
Use Local storage it works without internet. Storage is working online it needs internet to retrieve data. You have set data you can get data from storage by using the 'cartItems' key.
I'm working on a eZ publish 5 project. This CMS is based on symfony 2.
I have built a form without class as described in tge page : http://symfony.com/doc/current/book/forms.html#using-a-form-without-a-class
On the eZ publish 5 documentation (https://confluence.ez.no/display/EZP/Legacy+configuration+injection) I read that I need to set the CSRF intention parameter to 'legacy'. I can't figure how to do this. I tried to use the add method on my formBuilder :
$this->createFormBuilder()->add('_token', 'csrf', array('intention'=>'legacy');
But I get an error 'could not load type csrf'.
Can someone help me on this ?
Thanks.
Okay, I have given this a try.
My first answer is actually a question: If you don't intend to execute any legacy kernel code as a follow-up to your form, you don't need to care about the intention, I believe.
Intentions between the Symfony and legacy kernels only need to match if the Legacy Kernel is booted (in which case it will check if there is a token, and if it is valid).
If you need to use the Legacy Kernel, you can set the intention to legacy by passing custom form options:
$formOptions = array( 'intention' => 'legacy' );
$form = $this->createFormBuilder( null, $formOptions )
->add( 'text', 'text' )
->getForm();
Setting the default intention is explained in http://symfony.com/doc/current/book/forms.html#csrf-protection, but I wouldn't really advise this, unless you intend to only rely on the legacy kernel.
my question is in the subject.
I need to be able to test if my add-on sdk based extension is installed in order to open it programmatically.
How would I do that ?
Basically, I have a JS script checking for the web browser of the user and if my extension is installed, I'd like to redirect to a specific url, which will launch the opening of the extension.
I read that with XUL extension, adding a contentaccessible=yes to any image and testing it onload gives us the answer, but it seems we can't do that with add-on sdk based...
Any idea ?
Thanks anyway for reading me :)
You should look at the docs for the AddonManager:
https://developer.mozilla.org/en-US/docs/Addons/Add-on_Manager/AddonManager
Here is a code snippet that you coulde use to get going:
const { Cu } = require("chrome");
let AddonManager = Cu.import("resource://gre/modules/AddonManager.jsm").AddonManager;
AddonManager.getAddonsByTypes(["extension"], function(addons) {
var addonData = [];
for (let i in addons) {
let cur = addons[i];
addonData.push({
id: cur.id.toString(),
name: cur.name,
});
};
console.log(JSON.stringify(addonData, null, ' '));
});
I've hosted this code on the Add-on Builder as well:
https://builder.addons.mozilla.org/package/44810/latest/
Edit: Builder is EOL and will go offline in a month.
I'm trying to integrate Doctrine 2 into Zend Framework (I'm new to ZF). I've look everywhere on the net but couldn't find my answer...
I've followed this recent tutorial: http://hectorpinol.com/zend-framework-1-11-and-doctrine-2-2-x-integration/ and I've managed to generate a table using the CLI.
The last step of the tuto is to add a new line in this table, simply using the Index controller. But my website doesn't work anymore (a brutal error 500, no message) because I changed the bootstrap.
if I remove the last lines I added to the _initDoctrine() method, it works again (but without Doctrine of course). Here they are:
// set the proxy dir and set some options
$config->setProxyDir(APPLICATION_PATH . '/models/Proxies');
$config->setAutoGenerateProxyClasses(true);
$config->setProxyNamespace('App\Proxies');
// now create the entity manager and use the connection
// settings we defined in our application.ini
$connectionSettings = $this->getOption('doctrine');
$conn = array(
'driver' => $connectionSettings['conn']['driv'],
'user' => $connectionSettings['conn']['user'],
'password' => $connectionSettings['conn']['pass'],
'dbname' => $connectionSettings['conn']['dbname'],
'host' => $connectionSettings['conn']['host']
);
$entityManager = \Doctrine\ORM\EntityManager::create($conn, $config);
// push the entity manager into our registry for later use
$registry = Zend_Registry::getInstance();
$registry->entitymanager = $entityManager;
return $entityManager;
Do you have any idea to unlock the situation? It's frustrating because I know I'm so close to make it work...
UPDATE1: I forgot to mention, in case it helps: I'm using WAMP on Windows. Thanks
UPDATE2: Added the parameters of the create() function.
UPDATE3: Actually it might not be an error 500. Chrome says this but Firefox just displays nothing. No answer from the server.
1) Change the environment to development to see the error message.
2) Use Bisna library instead, will save a lot of time (I don't see a point in integrating Doctrine manually well only educational purposes but you might want to save it for later).