conditional,locale,thymeleaf,spring-el , Thymeleaf compare #locale expression object with string


Thymeleaf compare #locale expression object with string

Question:

Tag: conditional,locale,thymeleaf,spring-el

I want to set a th:class attribute depending on the context locale using the expression object #locale.

I have tried

th:class="${#locale}=='en'?'active':''"
th:class="${#locale=='en'}?'active':''"

Both of them results in false, but whent I print it with th:text="${#locale}, I got the correct locale code (en,es).

Any idea of how to compare the #locale object with a locale code?


Answer:

This is a issue that I told to the guys of thymeleaf time ago.

You need to resolve first the #locale before comparing it with "en". You can do that adding 2 underscore at the beggining and end to the expresion that you want to resolve first. In your case will be something like this:

th:call="$({__#locale__}=='en'?'active':'')"

Related:


One liner conditional, multiple variables and check that all of them are not false?


python,if-statement,conditional,conditional-statements
How I can make a conditional in python that checks for this three keywords defined in the dictionary and that they are not False ? settings = { 'proxy_host': '127.0.0.1', 'proxy_port': 8080, 'proxy_protocol': 'socks', } I have tried with the sentence you can see below. But this is only checking...

Deleting rows in R conditionally


r,conditional,delete-row
I have a data where the first column is a bunch of ID numbers (some repeat), and the second column is just a bunch of numbers. I need a way to keep each ID number only once based on the smallest number in the second column. Row# ID Number 1...

Show text for post with specific date and specific category in Wordpress


php,wordpress,date,conditional
So I'm trying to show text at the end of each post but from this month only and only in one category. I tried different codes that I found here but none of them really worked or what I needed. Here is example of what I like to do. Hope...

How to set a conditional based on multiple models?


ruby-on-rails,ruby,model-view-controller,notifications,conditional
notifications/index has <%= render partial: "notifications/notification", collection: @notifications %>, which contains: <% if Comment.find_by(notification.comment_id) == @habit %> <%= link_to "your habit", habit_path(notification) %> <% else %> <%= link_to "your value", valuation_path(notification) %> <% end %> which shows gives the error for the 1st line: Couldn't find Habit with 'id'= even...

“Gtk-WARNING **: Locale not supported by C library. Using the fallback 'C' locale.” on OSX


c,osx,gtk,locale
Background information: I use Mac OSX Yosemite. I've installed gtk+ using brew install gtk+ and fixed the errors using export PKG_CONFIG_PATH=/opt/X11/lib/pkgconfig. I've build my program using make but when I try to run it I get a warning like this: (process:16182): Gtk-WARNING **: Locale not supported by C library. Using...

How do I use Angular i18n for languages it doesn't appear to support?


javascript,angularjs,internationalization,locale,angular-translate
I am using Angular i18n for German, English, Spanish, French, Italian, Portuguese, Russian, Ukrainian, Japanese, Korean, and Chinese. These are all supported locales, but I've been tasked to include translations for Cebuano, Samoan, Tagalog, and Tongan. These do not appear to be supported locales in Angular i18n. How do I...

Chance of a conditional occurring in Swift: Xcode


xcode,swift,if-statement,conditional,percentage
I am quite new to Xcode and swift so sorry if this is a bad description. Is there a way that there is a chance of your conditional occurring so instead of it happening 100% of the time when the conditions are met, it only happens 50% of the time...

Combining two for-loops that share similar properties


javascript,loops,dom,conditional
I have two divs which numerically represent the width and height of the window's screen, counting from every 100th pixel. The numeric values are wrapped inside span tags and inserted into their respective div container through two loops. Since both of these loops share almost the same exact methods and...

.NET Application looking for DLLs in locale specific sub-folder


.net,dll,locale,app-config,subfolder
My company have some internal utility libraries containing things like base services, useful extension methods etc. I have recently completely re-written these from the ground up and have packaged them as nu-get packages, hosted on our internal network. When I've added added a NuGet reference to the packages in a...

Why is wstring_convert throwing a range_error?


c++,c++11,locale,wstring
I'm writing some code that needs to convert between byte strings and wide strings, using the system locale. When reading from a file, this is incredibly easy to do. I can use std::wifstream, imbue it with std::locale(""), and then just use std::getline. According to cppreference's codecvt page, wifstream just uses...

Elastic Search : General and conditional filters


elasticsearch,conditional,apply,exists
I'm using Elastic Search, with query match_all and filtering. In my situation I want to apply a general filter and filters by condition. Here in pseudo: query: match all (works fine) filter range date between d1 and d2 (works fine without bullet 3) filter (apply only if field exists, but...

Angular Filter Service inside Controller


javascript,angularjs,service,filter,locale
first post ever so be gentle!! Got an issue inside Angular 1.3 and using a Stateful Filter within a controller. In short when you use the $filter('custom')(data) method as a pose to the {{ data | custom }} method - and the cutom filter updates (say a service updates), only...

Using Razor Syntax within JavaScript Conditional Statment


javascript,c#,asp.net-mvc,razor,conditional
In an index.cshtml I have the following working code similar to: <script type="text/javascript"> if ([email protected]' === 'True'){ Do Something(); } </script> The === 'True' seems like an odd hack to me to force Razor and JavaScript to get along. How can I refactor to use === true? This doesn't give...

Returning a value from a function within a for-loop


javascript,function,loops,dom,conditional
I want to run a for-loop that appends every hundredth numeric value of the width of the screen into a div. This works: for (var i = 50, numbers = ""; i < limit; i+= 50) { if (num % 100 === 0) { numbers += i; } } document.getElementsByClassName("width")[0].innerHTML...

Conditional Logic for links in ACF


php,wordpress,if-statement,conditional,acf
So here is what im trying to do. Im using Advanced Custom Fields for this and am outputting a title with a link, But sometimes their is NO link. When there is NO link I don't want this to be wrapped in a tag but I can't seem to figure...

Get dates from AUT?


date,vbscript,locale,qtp,hp-uft
My Web-based application (like most) follows the browser locale to format dates. So if you configure British English as the preferred language in the browser, the app will display dates in "DD/MM/YYYY" format. Now QTP (ok, it´s VBScript that is the culprit) does not know about this. It strictly follows...

Spring MVC 3.1 change language i18n based on the request locale language


java,spring,spring-mvc,internationalization,locale
What I would like to do it to display the appropriate language to the user based on his request.getLocale().getLanguage(); So here is what I already have and which is already working fine. Meaning that when I type ?lang=en or ?lang=cn at the end of the URL it displays the appropriate...

Gnuplot: Conditional splot of a function


conditional,gnuplot
I want to splot the function exp(-(x²+y²)) alone and under the constraint of x+y-1=0. The result should be the surface alone as well as a line with a maximum at x=y=0.5. Or in other words, it's the intersection of the function with a (110)-plane. What I came up so far...

What is this error about perllocale in Perldoc?


osx,perl,debugging,documentation,locale
I was discussing here about setting no locales in Perl and was recommended to run this perldoc perllocale in OSX Yosemite 10.10.3 but I get the error: Error while formatting with Pod::Perldoc::ToMan: at /System/Library/Perl/5.18/Pod/Perldoc.pm line 1346. at /usr/bin/perldoc5.18 line 11. Got a 0-length file from /System/Library/Perl/5.18/pods/perllocale.pod via Pod::Perldoc::ToMan!? at /usr/bin/perldoc5.18...

Thymeleaf compare #locale expression object with string


conditional,locale,thymeleaf,spring-el
I want to set a th:class attribute depending on the context locale using the expression object #locale. I have tried th:class="${#locale}=='en'?'active':''" th:class="${#locale=='en'}?'active':''" Both of them results in false, but whent I print it with th:text="${#locale}, I got the correct locale code (en,es). Any idea of how to compare the #locale...

What is the correct way to get a LOCALE_SSHORTDATE that is guaranteed to have a full (4-digit) year number?


c,winapi,locale
I want to create a date-time picker control that shows both date and time, as a combination of the DTS_SHORTDATECENTURYFORMAT and DTS_TIMEFORMAT styles. Since there is no such style built into the date-time picker, I have to do it myself with GetLocaleInfoEx(). I notice that by default, GetLocaleInfoEx(LOCALE_SSHORTDATE) seems to...

FacesContext#getViewRoot() returns null while setting for first time


jsf,locale,jsf-2.2,mojarra
I am trying to change my JSF application locale in one page and that has to change all my pages locale. I have followed this link, and it works well JSF locale is set per request/view, not for session If I run the application I can change the locale in...

Keep the second occurrence in a column in R


r,conditional,subset,find-occurrences
I have quite a simple dataset: ID Value Time 1 censored 1 1 censored 2 1 uncensored 3 1 uncensored 4 1 censored 5 1 censored 6 2 censored 1 2 uncensored 2 2 uncensored 3 2 uncensored 4 2 censored 5 I want to keep the first uncensored occurrence,...

Laravel: Locale Session: Controller gets Parameter to change it but it cant. U have to hardcode it


session,laravel,locale
I tried to create a Form and do away with Ajax. Yes, the form at least does send the parameter down to the Controller as I var_dumped it and exited in order to see if it had gotten the new value, and yes it did, but guess what? and here...

Boo Language Calculation on Web Drop Down List


if-statement,conditional,boo
The software we use LanDesk Service Desk uses Boo Language calculations to allow for dynamic windows. I have a drop down list on a form that has one of two options. "Acute" and "Ambulatory". Based on which is chosen, one of two possible fields will no longer be hidden and...

Where is the LANGUAGE environment variable set?


linux,environment-variables,locale,configuration-files,archlinux
I'm using zsh on my archlinux. My LANGUAGE environment variable was set to fr but I wanted to set it back to en_US.UTF-8 so I did it in my ~/.zshrc file. But was it the best place to set it? Isn't it dirty? This works but only for my user's...

How to set font-weight of a column text to bold based on another column value in Telerik Grid


telerik,formatting,conditional,client-templates
I have a Telerik grid in which based on whether my IsTrue value is true or false, I need to set the font-weight of Name text in only that particular row to bold. I tried the following but I seem to be missing something. columns.Bound(d => d.IsTrue).Width(0).HtmlAttributes(new { id="hdnIsTrue", style...

How to set a double format by locale


java,locale,number-formatting,decimalformat
I those input strings: 10000,20 4000,10 5,400.20 I am trying to format them with locale: nf = NumberFormat.getInstance(Locale.FRANCE); double newLoc = nf.parse(split[5]).doubleValue(); And also like this: nf = NumberFormat.getInstance(Locale.ENGLISH); double newLoc = nf.parse(split[5]).doubleValue(); Result is: for Locale.FRANCE 5400.2 4000.0 10000.0 For Locale.ENGLISH 4000.0 10000.0 5400.0 But what in need is...

Conditional text for certain categories within taxonomy.php


wordpress,conditional,archive,taxonomy,easy-digital-downloads
I am building a Wordpress site using 'Easy Digital Downloads'. The downloads have their own 'categories'. To display an archive of those categories (different from the standard archive.php) I am using a template called taxonomy-download_category.php as specified in their documentation. This works perfectly and I can set up the category...

How to write a conditional on two variables (columns) in Pandas


python,pandas,conditional
I'm trying to count instances when there was no login, but there was a card-view, and create a new column with the count (or True). I used the conditional statement below and got a key error. Can someone help me figure out what's going on? import pandas as pd import...

Rails 4 validation conditional on value of a hidden field


ruby-on-rails,validation,conditional,hidden-field
How can I perform a validation only if the value of a hidden_field matches a specified value? For example, I have two forms each with a separate submit button and a separate hidden_field, the value of which determines whether to run one set of validations or another. The problem seems...

getting Locale session on Laravel and selecting query accordingly


laravel,locale
I am trying to just select a sql query depending on the session set for the locale language. Yet, as simple as it should be, now I am getting at the View an "invalid argument for the foreach array", that is, it is not passing arguments. Before having the check...

How should one redirect locale-less URIs to locale-full ones in Symfony-CMF?


php,symfony2,routes,locale,symfony-cmf
Background We have a (fairly typical?) arrangement for a multilingual Symfony CMF website, where resource paths are prefixed by the desired locale—for example: http://www.example.com/en/path/to/english-resource.html; and http://www.example.com/fr/voie/à/ressource-française.html. We are using RoutingAutoBundle to store such routes in the content repository, and DynamicRouter to utilise them: simple and easy. If a GET request...

.NET use IIF to assign value to different variables


.net,vb.net,conditional,variable-assignment,iif
Could I (and if so how) do the following in .NET language (more specifically VB.NET): Dim a,b as Integer if(somecondition=1,a,b) = 12345 Or any variant with IIF would be fine by me. Basically I'm always assign the same value but never to the same variable.....

Conditional group by join in R


r,join,conditional
I am new to R and rather flumoxed by the following problem. I have two vectors of dates (the vectors are not necessarily aligned, nor of the same length). I want to find for each date in the first vector the next date in the second vector. vecA <- as.Date(c('1951-07-01',...

Converting a number from a string to an int with decimals separated by comma or dot


c#,.net,xaml,numbers,locale
I have a string which contains a number. It can be one with decimals, followed by either a comma or a dot, depending on the user's locale. The numbers are actually hundredths and I want to convert them to plain old ints. For example, I want strings "14.5" and "14,5000"...

Formatting number in European format with two decimals


javascript,formatting,locale,culture
Trying to format a number to two decimals format in European culture. So that comma is decimal separator and space thousands separator. In example 213245 should be formatted as 213 245,00 How can I do that? 213245.toFixed(2).toLocaleString(); gives 213245.00 but it should be 213 245,00 however 213245.toLocaleString() gives 213 245...

Display current local time in Sofia in Hours : Minutes 24h format


javascript,asp.net,arrays,locale
I'm trying to display Sofia Local Time for every user that enters my website so that it does not matter what's the time of the user or the server of my website deployed. This is JS but it displays the user's time.How to display current time in Sofia/Bulgaria .I use...

Django: How to upload file without UnicodeEncodeError on save()?


python,django,file-upload,locale,python-unicode
IM try to upload a file but when the file name have caracters like "ó" have a 'ascii' codec can't encode character u'\xf3' in position 59: ordinal not in range(128) im try to obj.file = smart_unicode(form.cleaned_data["file"]) before save() on views.py and def file(instance, filename): i = datetime.now() filename = smart_unicode(filename)...

Change locale in android app (onto Hindi)


android,locale,hindi
Creating multi languages support for the app with possibility to change language in App settings. As for now everything works fine for English, Spanish, Franch, Russian languages, but doesn't work for Hindi and Chineese. 1) I specify the language name in original language but in the app instead of हिन्दी...

Conditional subtraction Part 2


r,conditional,multiplication
I have a big data.frame (TOTAL) with some values (cols11-16) that I need to subtract a base from which is multiplied by a value depending on two conditions in TOTAL. The data.frame (TOTAL) looks a little like this Channel Hour Category cols11 cols12 cols13 cols14 cols15 base TV1 01:00:00 New...

highlight “partial” duplicates across entire sheet in Google Sheets using conditional formatting


formatting,duplicates,conditional,highlight,partial
Im trying to highlight partial duplicates in google sheets using conditional formatting. I need to highlight duplicates across multiple columns and rows in any matching cells. so far I'm using this... =countif(INDIRECT({"C2:Z18"}),C2)>1 Which works to a degree, but it only highlights exact matches. I need to find a way to...

Create a Triangular Matrix from a Vector performing sequential operations


r,for-loop,matrix,vector,conditional
I have been trying to solve the following problem. Suppose I have the following vector: aux1<-c(0,0,0,4,5,0,7,0,0,10,11,12) where the numbers represent the number of the row. I want to calculate the distance between the differents elements of this vector fixing the first component, then the second and so on. If the...

How to parse “1,234.56” in Java as Double?


java,double,locale
I am having trouble parsing "1,234.56" in Java, a similar question recommend using French locale in number formatting, but it is parsing the result incorrectly. Here is what I have: NumberFormat format = NumberFormat.getInstance(Locale.FRANCE); Number number = format.parse("1,234.56"); System.out.println(number.doubleValue()); // Should get 1234.56, got 1.234 instead Number number = format.parse("1,234,567.89");...

Python AND OR statements


python,if-statement,conditional
I am parsing text with Python and I have this final code to write sentences, but it does not work well: opt = child.get('desc') extent = child.get('extent') if opt == 'es': opt = "ESP:" elif opt == "la": opt = "LAT:" elif opt == "en": opt = "ENG:" if opt...

MySQL Conditional Left Join With Default


mysql,left-join,conditional
Is there a way to make a conditional left join, which will left join on a default value if a match is not found? I have a client table and a preference table. Record 0 in the preference table is my global default preference. There are cases in which a...

Bash conditional statement


bash,conditional
I realize this is probably a really simple problem, but I can't figure out why this isn't working. I'm attempting to check if a folder is larger than 35GB and if so, remove all files that are older than 3 days in it. Like so: #!/bin/bash MAX=35000000000 if [ $(du...

Storing reference (hash?) to the node for conditional manipulation


performance,xslt,conditional
Given this pseudo-code: <xsl:variable name="check0"> <xsl:value-of select="($externalFile//i[@attibute = $variable]/..[email protected] < $genDate) and ($externalFile//i[@attibute = $variable]/..[email protected] > $genDate)"/> </xsl:variable> <xsl:variable name="check1"> <xsl:value-of select="($externalFile//i[@attibute = $variable]/..[email protected] < $genDate) and ($externalFile//i[@attibute = $variable]/..[email protected] > $genDate)"/> </xsl:variable> Above code checks if some variable is in date range of attributes taken from...

Is it bad that LANG and LC_ALL are empty when running `locale -a` on Mac OSX Yosemite?


c,osx,locale
I use Mac OSX Yosemite. When I run locale I get this: locale LANG= LC_COLLATE="C" LC_CTYPE="UTF-8" LC_MESSAGES="C" LC_MONETARY="C" LC_NUMERIC="C" LC_TIME="C" LC_ALL= Question 1: Does the emptiness of LANG and LC_ALL bad/normal/prefered? Normally, I wouldn't care that much about it, but I've got a warning (process:16182): Gtk-WARNING **: Locale not supported...