w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Language selection with Umbraco and XSLT
I am not sure why you are using the GetRelatedNodesAsXml method. I think you are taking a difficult approach here. I am not sure if you want to display only the flag of the current language or both flags This will display the flag of the current language: <xsl:variable name="languageNode" select="$currentPage/ancestor::*[@level = '1']" /> <ul> <li> <a href="{umbraco.library:NiceUrl($languageNode/@id)}" class="{$languageNode/@nodeName}"> <xsl:value-of select='$languageNode/@nodeName' /></a> </li> </ul> If you want both flags, try this: <ul> <xsl:for-each select="/root/*[@nodeType = 'add the nodeTypeID of your language items']"> <li> <a href="{umbraco.library:NiceUrl(@id)}" class="{@nodeName}"> <x

Categories : Xslt

The model item passed into the dictionary is of type 'System.Collections.Generic.List`1[X]', but this dictionary requires a model item of type 'X'
Take this at face value - yours is not unique. Your problem is you are passing an array of user to a controller action that expects a user. You need to post your HTML but it is probably something like @model List user or something instead of a single user. If your model represents a single user then pass that to the controller. If opposite, do opposite, If you want to pass a list to the controller use list users edit make your razor syntax @model Mike.Models.User

Categories : Asp Net Mvc

Select "umbraco item" using razor
You cannot use server tags inside your razor template. tags like: <umbraco:Item field="field_1" runat="server" /> But you can call @Model.field_1 Final version should look like that: @if (condition) { @Model.field_1 } else { @Model.field_2 } Check this post about razor macros in umbraco: http://www.diplo.co.uk/blog/2011/6/17/using-razor-in-umbraco-47.aspx

Categories : Asp Net Mvc

Unique Name for Navigation Item in Umbraco
Okay, I never understood what I was reading when I kept seeing articles about umbracoUrlName, but I finally figured it out. Basically, I keep the code above the same, but I just changed the alias from menuItemName to umbracoUrlName (it is a textstring) and whatever I put in there is what the URL is for that page! Geeze, I feel silly now, but at least it is working!

Categories : Xslt

In Umbraco 6.1.1 MVC 4, how can I do a form post back to a surface controller using a model that inherits from Umbraco's RenderModel?
Ok, I've had no responses to this question but am now in a position to answer it myself. Maybe it was a fundamental oversight, but not that obvious imho, and information on the Umbraco forum etc about inheriting from RenderModel is fairly limited. Essentially the answer, as was my first instinct, is to solve the original exception "No parameterless constructor defined for this object" by providing a paramaterless constructor. The difficulty is working out what to put inside the parameterless constructor for my model, since it inherits from the Umbraco RenderModel which requires an IPublishedContent instance passed to it's constructor. Luckily while browsing around I happened across this post on the Umbraco forum: http://our.umbraco.org/forum/developers/api-questions/40754-Getting-Curre

Categories : Asp Net Mvc

Umbraco MVC Implementation - View does not depend on Umbraco implementations
No you can't. Simply because all requests pass through a single action. In order to retrieve a path to a CMS-managed page, you need to use the node/content traversal the @Model provides. See here for more details on this. Edit To clarify, the author of the article is suggesting that the Umbraco implementation should be more in line with a traditional MVC implementation with little or no logic in the views. Therefore, any querying of node data should happen prior to the view (e.g. in the Mappers). So this is where you would have to retrieve the links. Umbraco's default MVC implementation forces all requests to go via a single action on a single controller. The author's implementation allows the requests to be shared across one controller per document type - which is better IMO. But it st

Categories : Asp Net Mvc

Umbraco MediaService / Umbraco MediaItem not saving
To Save media, I found this method with MediaService. However, I think it's possible another method more refined [HttpPost] public JsonResult Upload(HttpPostedFileBase file) { IMedia mimage; // Create the media item mimage = _mediaService.CreateMedia(file.FileName, <parentId>, Constants.Conventions.MediaTypes.Image); mimage.SetValue(Constants.Conventions.Media.File, file); _mediaService.Save(mimage); return Json(new { success = true}); }

Categories : C#

Umbraco - error when using umbraco.library:NiceUrl(...)
Ok I found a solution: I added an extra check to this part: <!-- Return the url --> <xsl:if test="$i = $max"> <xsl:if test="$id != '' "> <xsl:value-of select="umbraco.library:NiceUrl($id)" /> </xsl:if> </xsl:if> this fixed my problem.

Categories : Xslt

Could not locate Razor Host Factory type: umbraco.MacroEngines.RazorUmbracoFactory, umbraco.MacroEngines
If you are trying to host the blogengine site within a virtual directory of the Umbraco site, then you will have to amend the blogengine web.config to "remove" all the Umbraco-specific handlers and modules, as these will be inherited by the blogengine application, causing this exception because the application can't find the relevant DLLs in its bin folder. I recently had a similar problem and I have posted the web.config I used in the virtual directory below. Mine was a very simple web application, so obviously this will not work by itself in your blogengine app. You will need to add the relevant parts into your web.config file. Also, this was for a v6 Umbraco install in IIS7.5, so you may have to experiment a little. <?xml version="1.0"?> <configuration> <configSecti

Categories : Iis

Dictionary.Item in C#
Dictionary<string, decimal> dictionary = null; Person oPerson = null; string key = "SomeValue"; if (dictionary.ContainsKey(key)) { oPerson = dictionary[key]; } Dictionary<string, decimal> dictionary = null; Person oPerson = null; string key = "SomeValue"; if (dictionary.ContainsKey(key)) { oPerson = dictionary[key]; }

Categories : C#

Dictionary item order
Dictionaries are not ordered at all, so you can't rely on the values there. You could try using OrderedDictionary. If you prefer a generic one, check the following link: No generic implementation of OrderedDictionary?

Categories : C#

add an item to array of dictionary
Your objects created from JSON are all immutable. self.seachResult =[NSJSONSerialization JSONObjectWithData:responseData options:nil error:nil]; instead of passing nil for options pass NSJSONReadingMutableContainers: self.seachResult =[NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingMutableContainers error:nil]; From the NSJSONSerialization docs: NSJSONReadingMutableContainers Specifies that arrays and dictionaries are created as mutable objects.

Categories : Objective C

Skipping to Next item in Dictionary
Use continue: for key, value in mydict.iteritems(): if key == 'skipthis': continue Also see: Are break and continue bad programming practices?

Categories : Python

An item with the same key has already been added to dictionary
The exception is caused by trying to add an item to the InterfaceSettings Dictionary object which has a key which matches the key of an item that has already been added. I think these are possibilities: The DataTable "tblData" contains rows with duplicate "SettingsName" values. The InterfaceSettings Dictionary object is not empty when you start adding DataRow values and already contains an item with a key matching one of the "SettingName" table row values. The same instance of InterfaceSettings can be seen by two or more threads which access this code. One thread adds an item and subsequently another thread attempts to add the same item. I had a similar issue in my ASP.Net web application where a Hashtable variable belonging to a Module threw an Object not set to an instance of an obj

Categories : Vb.Net

Dictionary vs List for looking up an item
Dictionary is faster than List in assimptotic meaning of the word: O(1) < O(n); it means that there's such a size X from which on Dictionary starts being faster than List. E.g. if Dictionary/List contains, say, 10000 or more items, Dictionary is always faster (if there're fewer items to store, say, 5, List can well be faster). There's another issue with Dictionary: it requires GetHashCode() method; if GetHashCode() is bad implemented Dictionary can be deadly slow.

Categories : C#

How to call an item from a dictionary in python?
It is much easier to have python do the lookup for you. Ignoring empty lines for now: elements = [] for line in open("periodic_table.txt"): elements.append(line[3:]) You can then do a lookup like this: if answer.isdigit(): print elements[int(answer)] else: print elements.index(answer)

Categories : Python

Naming each item in a list which is a value of a dictionary
If you're just trying to print that: for k, v in dct.iteritems(): print repr(k)+ ":(" + ", ".join("Country{}:{}".format(i,c) for i,c in enumerate(v, start=1)) + ")" Output: 'Europe':(Country1:Germany, Country2:France, Country3:Italy) 'Asia':(Country1:India, Country2:China, Country3:Malaysia) Note: I'm abusing the function of repr() to get the quotes in there. You could just as well do "'" + str(k) + "'". The reason why your code doesn't work is your use of : outside of a dictionary initialization or comprehension. That is, you can do d = {'a':'b'} but you can't do print 'a':'b'. Also, you shouldn't use dict as a variable name, because it is a keyword. My solution will work for tuples which have more (or even less) than 3 elements in them, too.

Categories : Python

Insert item at the beginning of dictionary
Dictionaries are not ordered - they are effectively a Hashtable structure that provides O(1) direct lookups. Therefore you are using the wrong data structure for an ordered collection. You might be better off with a List<KeyValuePair<int, string>> as the List will respect the order that items are added/inserted.

Categories : C#

How to Add an item to ArrayList and Dictionary using reflection
To add an Item to a Generic.List<T> you use the Add method Example: MyArray.Add(1); For Generic.Dictonary<T> you also use the Add method, but supply 2 values, Key and Value MyDictionary.Add("MyKey", "MyValue"); So you can just loop though your PropertyInfo[] and add whatever you need to your List<T> or Dictionary<T> foreach(var prop in properties ) { MyArray.Add(a number from somewhere); MyDictionary("some key", "some value"); }

Categories : C#

Multi language settings and getting string array item - android
Okay I got your solution: First of all: String celcius = sharedPrefs.getString("prefTempUnit", "Celcius") will return "Celcius" as a default value. Maybe you should remove it? Second: If you would like to access the String value according to the actual language, you should use: String retrievedValueFromStringXML = getResources().getString(R.string.celcius); To add: ListPreference has a method called getValue(), you should use it as well to retrieve the actual value.

Categories : Android

Cleaner way to group dictionary item on 2 levels
You can somewhat simplify this by interpreting sets of numbers as sets of bits. Convert a set of small numbers 0..11 to a single int such that if a number k is present in the set, then bit number k is set in the int; otherwise, the corresponding bit is zero. For example, your illustration would be converted to a number 010 001 101 011 in binary (spaces are for separating the groups). Note that the bits are reversed, because cell #1 is on the left, while bit number zero is on the right. This corresponds to octal number 2153 (octal is convenient when you consider triples of bits). Given a mask like that, you can check each triplet of bits for validity. There are only eight possibilities - 000, 001, 010, 011, 100, 101, 110, and 111. Of them only 000, 011, and 101 are valid. Here is one wa

Categories : C#

How to access Dictionary.Item Property in C#
Use groups[n]. If you look at the manual for Dictionary<TKey, TValue>.Item, you may find: This property provides the ability to access a specific element in the collection by using the following C# syntax: myCollection[key]. Or search the web for "C# indexers": Indexers Tutorial (C#): Defining an indexer allows you to create classes that act like "virtual arrays." Instances of that class can be accessed using the [] array access operator. Indexers, or Item in this case, are never directly accessed.

Categories : C#

How to display in a new window the last item of each dictionary in a list of dictionaries?
You can get the list of sentences using a list comprehension: listOfDict = [{'variable1':1, 'variable2':10, 'sentence':'I am currently working'}, {'variable1':2, 'variable2':20, 'sentence':'How are you today?'}] sentences = [d['sentence'] for d in listOfDict] print(sentences) which prints out: ['I am currently working', 'How are you today?']

Categories : Python

Exception thrown during test, leads to Item has already been added in dictionary
If any of your membership provider objects are static or a shared reference, and you're adding the "john" user in multiple tests, then you have a race condition as tests are executed in parallel/multithreaded. To resolve, you'll have to either configure a test setup/teardown that clears the data structures per test, and execute them sequentially, or wrap these objects in a custom object programmed to an interface that you can mock.

Categories : C#

How to get iOS resource dictionary from resource path for current language?
Don't do any of that. You localize the storyboard by editing the .strings file that goes with it for the appropriate language. When iOS displays the view, it'll automatically grab the proper localization and display it. EDIT: If you want to pull something from the strings file, do something like this: [[NSBundle mainBundle] localizedStringForKey:@"someKeyHere" value:nil table:@"MainStoryboard"];

Categories : IOS

python dictionary error AttributeError: 'list' object has no attribute 'item'
result = sorted(result.iteritems(), key=operator.itemgetter(1)) result is not a dictionary anymore. If I am not mistaken, your problem can be solved this way (assuming lines comes from somewhere): result = sorted({(calculate_score(line), line) for line in lines}) print(result[:20]) Take a look at OrderedDict for making an ordered dictionary.

Categories : Python

Issue with Dictionary type, If gived a specific text then get the equivalent dictionary key or dictionary value?
If this were my application, I would change the UI element to a datagridview so that I could bind a collection containing a custom class and just hide or show the appropriate columns as needed. This approach will allow you to easily add additional property columns in the future without worrying about the problems you are currently facing. It would also allow you to extend the UI to other platforms (mobile, web) without a lot of hard-coded information in the UI. For example, I would create the following class and collection to hold info about the files: Public Class FileDetails Public Property Index As Integer Public Property Description As String = String.Empty Public Property FullFileName As String = String.Empty Public ReadOnly Property FileName As String Get

Categories : Dotnet

QLocale detects system language incorrectly on Windows with language pack installed
When I was working on Localization in Qt, I used QString locale = QLocale::system().name(); When I tested getting the locale, I found it was dependent on the Format in the Region and Language settings: Control Panel > Region and Language > Format Hope that helps.

Categories : Windows

How can i fix language for the grammar does not match the language of the speech recognizer error in vb
I have worked this out. You can fix this by using this code before declaring the recogniser First import this Imports System.Threading Imports System.Globalization Secondly add this Thread.CurrentThread.CurrentCulture = New CultureInfo("en-GB") 'or your current language and country' Thread.CurrentThread.CurrentUICulture = New CultureInfo("en-GB") 'or your current language and country'

Categories : Vb.Net

Serving a language file depending on language preference settings
The way I'm doing it is to keep several separate language files, figure out the browser's language setting and then load the appropriate file. Here's the function I'm using (most likely not perfect, but it does what you'd expect): function loadLanguage() { "use strict"; if (window.navigator.language) { LocalLanguage = window.navigator.language; } else if (window.navigator.userLanguage) { LocalLanguage = window.navigator.userLanguage; } else { LocalLanguage = "en"; } var fileref = document.createElement('script'); fileref.setAttribute("type", "text/javascript"); switch (LocalLanguage) { case "cs-CZ": case "cs": LocalLanguage = "cs"; fileref.setAttribute("src", "Language/cz-CZ.js"); document.getElement

Categories : Javascript

Get keyboard language or detect user input language in Android
No. There's a phone locale, but the keyboard may ignore it by design (many keyboards allow you to switch languages just within the keyboard for bilingual users). There's no API for the keyboard to report it has done so to the OS.

Categories : Java

2 menus in different language points to same menu in main language
I did the same thing in the last week. You should have something like this: Two articles in different languages, or one common article. Then you choose in menu the type (e.g. single article) and set the title of the first menu item to loginasEN, and the second to loginas. Both are child of pages menu. For each submenu you choose the article in the specific language (en/lt), or the same article (e.g in your case english) to both sub-menus of pages. This is the common procedure. And it works perfectly. Joomfish is a great help.

Categories : Joomla

Retrieve tweets language or filter by language with TwitterStream
I don't think you can rely on iso_language_code - I couldn't find reference to it in the REST or streaming APIs. Tweets do have a lang attribute which indicates the language that the Tweet was written in. This was recently added to the API and, unfortunately, Twitter4J does not yet provide you with access to it. There is a task to add it in version 3.0.4 but the work does not to appear to have started yet. Unfortunately you'll need to wait until they add it or perhaps you could give them a hand and submit a pull-request.

Categories : Java

updating list values of dictionary with the values of another dictionary and printing the result as the values of first dictionary in python
Well, first off your syntax for defining literal dictionaries is incorrect. Dictionaries are surrounded by curly brackets like this: {} instead of square brackets like this: [] If you want 'Standard_Animator' and 'Extended_Animator' to be keys for lists of colors, you would want to do something like this: legenddict = {"Standard_Animator" : ["blue", 3f7fff, 00bfff, 3fffbf, "green", bfff3f, ffbf00, ff7f00, "red"], "Extended_Animator" : ["lightgray", "blue", 3f7fff, 00bfff, 3fffbf, "green", bfff3f, ffbf00, ff7f00, "red", "magenta"} colordict = {'blue':'ff00ff', 'red':'808080', 'lightgray':'d3d3d3', 'magenta':'00ff00'} So, to print the values in legenddict using the color names in colordict, you can check to see if the colors are keys in colordict, and if so, look up the

Categories : Python

Wrong language fonts at multi language app
the problem is that your phone doesnot supports unicode characters for greek, there are two solutions, 1)It means that fonts your device uses do not support greek characters (hence unknown unicode). You need to find better font and use it in your application (see http://developer.android.com/reference/android/graphics/Typeface.html docs) 2)get online unicode converter or google translator for english to greek and copy the words to your strings.xml

Categories : Android

difference between meta language and markup language?
Markup language:- A (document) markup language is a modern system for annotating a document in a way that is syntactically distinguishable from the text. The idea and terminology evolved from the "marking up" of paper manuscripts, i.e., the revision instructions by editors, traditionally written with a blue pencil on authors' manuscripts. In digital media this "blue pencil instruction text" was replaced by tags, that is, instructions are expressed directly by tags or "instruction text encapsulated by tags". Metalanguage metalanguage is language or symbols used when language itself is being discussed or examined.1 In logic and linguistics, a metalanguage is a language used to make statements about statements in another language (the object language). Expression

Categories : HTML

Python ordered dictionary: Why is [] notation required to change dictionary values using a for loop?
In the loop, name and val are bound to each of the objects in the mapping in turn. Simply rebinding the names will not modify the original iterable.

Categories : Python

SignalR Adding/Removing Connections from a dictionary and finding Group values from dictionary
First of all, SignalR is pretty smart about not wasting resources when sending to groups without any subscriptions, so you should be fine sending to groups without any members as long as it's OK to waste a few cycles doing that. If you don't have too many organizations you can have a ConcurrentDictionary<int,int> with all your organization ids as your keys and the number of connected members as your value. In OnConnected and OnDisconnected in could use Interlocked.Increment and Interlocked.Decrement respectively to keep track of the currently connected members. Then in your task could loop over the keys and skip any organization with zero connected members. This new ConcurrentDictionary could replace _uniqueOrganizations if you don't mind calling key.ToString(CultureInfo.InvariantC

Categories : Asp Net

How can I implement a fuzzy search across each value of a dictionary in a multiple dictionary list?
You can use something like >>> l = [ ... {"Name":"Arnold", "Age":"52", "Height":"160"}, ... {"Name":"Donald", "Age":"52", "Height":"161"}, ... {"Name":"Trevor", "Age":"22", "Height":"150"} ... ] >>> >>> [d for d in l if any("nol" in v for v in d.values())] [{'Age': '52', 'Name': 'Arnold', 'Height': '160'}] >>> >>> [d for d in l if any("52" in v for v in d.values())] [{'Age': '52', 'Name': 'Arnold', 'Height': '160'}, {'Age': '52', 'Name': 'Donald', 'Height': '161'}]

Categories : Python

Check if dictionary key contains any of another dictionary's keys and print matching pairs
This worked for me: full_name1 = 'Will Smith' full_name2 = 'Matt Damon' full_name3 = 'Mark yMark' name1 = 'Will' name2 = 'Matt' name3 = 'Mark' my_dict = {full_name1 : 1, full_name2 : 2, full_name3 : 3} another_dict = {name1 : 'x', name2 : 'y', name3 : 'z'} result = {} for sub, val in another_dict.items(): # start with the substrings for string, key in my_dict.items(): if sub in string: result[key]=val print(result) I used dict.items() to make the code a bit more readable. Combined with some more clear variable names, I think that makes the logic a bit easier to follow. docs: http://docs.python.org/2/library/stdtypes.html#dict.items Could be simplified I'm sure. Note that I assumed that your words like

Categories : Python



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.