UI5 disable internationalisation - sapui5

I started a new application on the SAP HANA Cloud platform. However when I start it i get the following errors:
GET https://webidetesting5949052-p1940909951trial.dispatcher.hanatrial.ondemand.com/resources/sap/m/messagebundle_de_DE.properties 404 (Not Found)
GET https://webidetesting5949052-p1940909951trial.dispatcher.hanatrial.ondemand.com/webapp/i18n/i18n_de_DE.properties 404 (Not Found)
GET https://webidetesting5949052-p1940909951trial.dispatcher.hanatrial.ondemand.com/webapp/i18n/i18n_de.properties 404 (Not Found)
and so on....
However I never started to use i18n and I just want to disable it. I cant find anything in the manifest and I am not loading a i18n model anymore.
How can I resolve this issue? I dont want to use i18n, as it just clutters my code.

The first missing file is from within the framework. Some of the controls in sap.m have translatable text, and afaik there is nothing you can do about it.
The other lines suggest that you are instantiating an i18n model somewhere. Check your manifest.json or Component.js or neo-app.json for such an entry. These are the files where you'd normaly setup your models, including the i18n model.
Edit: It seems like you are using the WebIDE. To remove i18n from manifest.json, switch to Code Editor
If you don't want to use i18n in your code, don't use it. But the code of the framework itself heavily relies on that feature and no hardcoded strings are stored inside a .js file. If there actually was a way to disable i18n, then for example the sap.m.DatePicker wouldn't work anymore, since all strings for months and days are stored in one of the property files.
Btw I think having your logic (JS code) separated from content (i18n strings) is awesome and quite the opposite of cluttered code. All big mobile platforms (Android, iOS) and probably alot more frameworks support that feature. But that's just my 2 cents.
TL;DR don't instantiate your own i18n model, ignore the framework's errors

Related

Can Emmet Be Used to Create FXML?

I have a scalaFX app that currently has its views created programmatically. I am wondering if I can use the Emmet tool to create FXML (particularly ScalaFXML) because I want to recreate my views in ScalaFXML to separate my views from my controllers more effectively. I have searched the internet and cannot find out if this is possible. So far I have only used Emmet for HTML. Thanks in advance for the help!
I have been looking around for something for PrimeFaces; I had trouble finding anything. I guess maybe it's because people who are using it are actually writing "normal" HTML with JS frameworks.
The good news is, it's completely (and easily!) customizable: just find the installation directory, and edit the "snippets.json" file, or create a new one called (for example) snippets-scalaFX.json. Mine on a Windows 10 machine, installed as a plugin for NPP, was C:\Program Files (x86)\Notepad++\plugins\EmmetNPP\emmet\snippets.json.
It's pretty obvious once you get in there, but inside the "snippets" object just add some more fields for yourself. For example, to make a PrimeFaces commandButton tag I added:
"pc": "p:commandButton"
You can use $0 or ${<placeholder text>} to define tabstops for expanded snippets, and | to define the caret starting point.
Full docs on editing snippets are here.

Sailsjs disable a single js

Right now, I am using <%- assets.js() %> to include all the javascript files on all pages. So, it means all the functions will be initialized on all pages.
I am wondering how can I disable a javascript file on a specific web page? Or, if there is a way to include some of the javascript files on a specific web page but not all the javascript files.
The trouble with the auto-loading is that it's really hard to dictate the ordering of the source files in any meaningful way-- it really comes down to how you've structured the front-end.
In v0.8.x (the version you're working with, from what I can tell), you can use the config/assets.js to control the ordering of folders that get loaded in. This is not ideal, but is a decent workaround that my team used on several projects.
In v0.9, we've removed rigging/asset-rack in favor of tight integration Grunt, which has a large community and some really cool and well maintained packages for most types of asset bundling, etc.
In any case, here are the different approaches you can investigate for serving assets in the new version of Sails.js:
Treat it just like anything else
In your layout.ejs file, create <link /> and <script></script> tags to link in your css and javascript files like you would normally.
Use AMD (Require.JS)
I think lots of folks would say this is actually the best option. Require is a pretty powerful tool. And I'm mostly in agreement-- if you're working with front-end javascript that could be coming from anywhere, and is going to be extended by other developers who may be using a different framework, AMD is a great way to make sure you stay safe. If you're using Require, each js file is its own module, and declares its own dependencies, so asset dependency management becomes a thing of the past. Then in production mode, there are a couple of different options to compile and minify your CSS and JS. You can even dynamically load templates and CSS from JS with Require, which is pretty neat. AMD/RequireJS is a hands-down winner if you're interested in loading some or all of your assets asynchronously. It's also an all-client-side solution, which is pretty cool.
The only downside in my mind is the complexity. If you have control over the framework being used, you really shouldn't have to manually enter dependencies for each file-- it can figure that out itself (see https://github.com/balderdashy/mast/blob/2.x/lib/raise.js)
Use Grunt
When you make a new project with sails new foo in Sails v0.9, a file called Gruntfile.js is created. It has lots of stuff in it, a lot of which isn't being used by default. You can do almost anything with Grunt, but in particular, you'll want to look at how it's set up to copy files from assets/* to .tmp/public/.
sails new foo --linker (Sails v0.9 only)
Linker is a lot like what asset-rack/rigging does currently. It creates the same Gruntfile as #3 above, but utilizes more of the contents. It will auto-link files in the order you specify. Instead of view partials (e.g. <%= %>), the scriptlinker plugin allows you to customize the delimiters where js, css, and templates will be injected. By default, the Gruntfile is set up to use JST precompiled templates, but again, you can set it up however you like.
Hope that helps guys, and best of luck!
-Mike
PS- v0.9 is coming out very very soon, I've just been working through tests and issues to make sure we're 100% there. If you'd like to try it out, check out:
https://gist.github.com/mikermcneil/5930330
The lead for Sailsjs replied to this issue (though it was about selecting CSS files):
"For now, you can (a) bring in all styles all the time and make only the relevant ones apply (b) use another tool (like Grunt) to bundle assets like you would in a vanilla node.js project or (c) link the stylesheets manually (put them in your public folder)."
See: choosing assets sailsjs
Similar, more complex questions have been asked in the Google group:
https://groups.google.com/forum/#!topic/sailsjs/yt9EpJlfzXA
Considering the above, you may want to have a separate layout.ejs for each page. You can specify the layout.ejs you want for each page with
res.view({ layout: "different_layout" })
The layout.ejs would (a) not call assets.js() but have < script > for all the js files needed, or (b) call assets.js() to serve all the common js files in ./assets/js plus < script > to serve the page dependant ones residing elsewhere.
I have a wrapper around assets.js() that allows you to include all assets except for specified files. You can also use it to include only specific assets elsewhere. So you could load your common assets in layout and include other assets only on pages where they are required.
See my answer to How can I include javascript assets selectively in SailsJS?

How do I load a custom font from an embedded file into DirectWrite in a Metro app?

I have been fighting a losing battle against loading fonts from an embedded file for use with DirectWrite. I am writing a simple puzzle game that has a C#/XAML interface but also uses SurfaceImageSource to add some DirectX content.
I have written a WinRT component that handles all of the DirectX code, and it works quite nicely. Some of my DirectX content is text drawn using the DirectWrite API. I can draw all the text I like so long as I'm loading an installed font from the system using IDWriteFactory::GetSystemFontCollection(), etc. But, I cannot seem to find a way to load a custom font from an embedded file.
From what I can tell Metro apps are not allowed to load files from the filesystem in the same way as a traditional app. So, the IDWriteFactory::CreateFontFileReference() method that takes a normal file path is worthless to me, right? I need to load my file from an ms-appx URL.
So, I wrote a custom font loader in my WinRT component that implements the IDWriteFontCollectionLoader interface (which is a ton of work if you've never done it before btw) that loads the font from an ms-appx URL using the new StorageFile API. Now, I can load my IDWriteFontFile and I can get a IDWriteFontFace, but if I try to call any of the truly useful methods on the font face it returns E_UNEXPECTED. I can get the number of glyphs and the glyph indices, but if I try to call something like GetGlyphRunOutline() or GetDesignGlyphMetrics(), it fails with E_UNEXPECTED. Using the same drawing code that generates an ID2D1PathGeometry using GetGlyphRunOutline() works great as long as I install the font file and get the IDWriteFontFace through the series of calls starting with IDWriteFactory::GetSystemFontCollection(). I am working with a normal true type font.
So, how do I load a custom font from an embedded file into DirectWrite in a Metro app? I'm probably just missing something easy, because I am certain that other people will want to be able to load custom fonts in this way.
I have a sample project (or could prepare one easily) for anyone who can help me identify my problem.
I have loaded the two IDWriteFontFace objects side by side, and I tried to figure out what is different between the one that works and the one that breaks. What I need to see in order to find out why it is failing is opaque to me hidden behind inside the IDWriteFontFace interface. HELP PLEASE!
Question also posted here: Building Metro style games with DirectX Forum
Well, the answer is... don't write a IDWriteFontCollectionLoader! You can use IDWriteFactory::CreateFontFileReference() with the StorageFile API. I was under the impression from all of the Microsoft Conference talks I had attended that in Metro you would be unable to access the native file system directly; the way forward would be to use the StorageFile API which references resources, etc. using ms-appx URLs. I understood that this was done for concurrency and to allow the OS to insulate itself from Metro apps that would be downloaded from the store by creating a file system sandbox. I think that is accurate. But, I feel like I was led to believe that we would never be able to get native file system paths. That is NOT true. IStorageFile provides a way. Just use IStorageFile.Path. I never looked at it because I just assumed the Path property would hold the ms-appx URL that I used to create the object. Microsoft probably provided this for exactly the purpose in my problem above: calling legacy COM interfaces that require a native path.
I haven't done any testing to determine whether the WinRT framework actually sandboxes you if you try to access a native file system path outside your own app package. I'm betting that it does...

Zend Framework contextually load stylesheets

Is it possible in Zend Framework to contextually autoload a stylesheet based on a unique identifier?
I'd like to load css based on the layout and the action name by first checking if the stylesheet exists then loading it.
Is that possible?
Yes it is possible and surprisingly simple to implement. I have just started trying this for myself in a small project I am working on.
See Andy Baird's blog on this, which also includes the code you need to get you started. He continues it in a second blog which takes the concept slightly further.
He uses the same technique for both CSS and javascript files, so you may want to try it with both too.

How to create custom pages in dasBlog?

I know I've seen this in the past, but I can't seem to find it now.
Basically I want to create a page that I can host on a dasBlog instance that contains the layout from my theme, but the content of the page I control.
Ideally the content is a user control or ASPX that I write. Anybody know how I can accomplish this?
The easist way to do this is to "hijack" the FormatPage functionality.
First add the following to your web.config in the newtelligence.DasBlog.UrlMapper section:
<add matchExpression="(?<basedir>.*?)/Static\.aspx\?=(?<value>.+)" mapTo="{basedir}/FormatPage.aspx?path=content/static/{value}.format.html" />
Now you can create a directory in your content directory called static. From there, you can create html files and the file name will map to the url like this:
http://BASEURL/Static.aspx?=FILENAME
will map to a file called:
/content/static/FILENAME.format.html
You can place anything in that file that you would normally place in itemTemplate.blogtemplate, except it obviously won't have any post data. But you can essentially use this to put other macros, and still have it use the hometemplate.blogtemplate to keep the rest of your theme wrapped around the page.
I did something similar setting up a handler to stream video files from the blog on my home server. I ended up ditching it because it killed my bandwidth whenever someone would view a video, but I did have it up and working for a while.
To get it to work I had to check dasBlog out from source control and open it in visual studio. I had VS2008 and it was built using VS2005, so it took some work to get everything to build. Once I could get the unaltered solution to build I added a new class library project to hold my code. This is to make sure my code stays separate across dasBlog updates.
I don't have access to the code here at work so I can't tell you exact names right now, but if you want your pages to be able to use the themes then they need to inherit from a class in the newtelligence.dasBlog.Web namespace, and I believe also implement an interface. A good place to look is in FormatPage and FormatControl.