Day of Week problem Language

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
lzonca
Posts: 16
Joined: 2019-03-11 14:48

Day of Week problem Language

Post by lzonca » 2020-06-19 15:40

Hi everyone :D .
I applied this formula to receive the day of the week (calculated Fields) but it is returned to me in English. how do I get it in Italian ?? Thanks

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: Day of Week problem Language

Post by pbottcher » 2020-06-20 07:20

Can you post the formula :-)
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

lzonca
Posts: 16
Joined: 2019-03-11 14:48

Re: Day of Week problem Language

Post by lzonca » 2020-06-20 07:53

OPS!!
this is the code calculated Fields

Code: Select all

SELECT DAYNAME(`Servizi`.`data_servizio`) FROM `Servizi` 
WHERE `Servizi`.`id_servizio`='%ID%'
data_servizi is data from timepicker

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: Day of Week problem Language

Post by pbottcher » 2020-06-20 08:57

Try

Code: Select all

SET @@lc_time_names = 'it_IT';SELECT DAYNAME(`Servizi`.`data_servizio`) FROM `Servizi` 
WHERE `Servizi`.`id_servizio`='%ID%'
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

lzonca
Posts: 16
Joined: 2019-03-11 14:48

Re: Day of Week problem Language

Post by lzonca » 2020-06-27 16:46

hi, I replaced the query on the calculated field, but it doesn't work, remains empty

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: Day of Week problem Language

Post by pbottcher » 2020-06-27 19:12

Can you run

Code: Select all

SET lc_time_names = 'it_IT';SELECT DAYNAME(`Servizi`.`data_servizio`) FROM `Servizi` 
WHERE `Servizi`.`id_servizio`='%ID%'
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

lzonca
Posts: 16
Joined: 2019-03-11 14:48

Re: Day of Week problem Language

Post by lzonca » 2020-07-06 13:02

Thanks, I tried the new code, but it doesn't work. empty field
Attachments
Immagine.jpg
Immagine.jpg (116.15 KiB) Viewed 3264 times

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: Day of Week problem Language

Post by pbottcher » 2020-07-06 19:34

Hi,

after looking deeper into it, i'm afraid that this is not possible to do it via the calculated field.
All i could suggest is that you use replace(FIELD, SEARCH, TARGET) and use it multiple times for the whole week.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: Day of Week problem Language

Post by jsetzer » 2020-07-06 21:15

Code: Select all

SELECT ELT(dayofweek(`FIELDNAME`), 'Dom', 'Lun', 'Mar', 'Mer', 'Gio', 'Ven', 'Sab')
FROM `TABLENAME` 
WHERE `PKCOLUMN`='%ID%' 
Please note that first entry in list of days is Sunday, because (by default) week starts on Sundays in MySQL databases.

Just replace:
  • FIELDNAME (your date field)
  • TABLENAME your table name
  • PKCOLUMN your primary key column name
In your specific case:

Code: Select all

SELECT ELT(dayofweek(`data_servizio`), 'Dom', 'Lun', 'Mar', 'Mer', 'Gio', 'Ven', 'Sab')
FROM `Servizi` 
WHERE `id_servizio`='%ID%' 
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: Day of Week problem Language

Post by jsetzer » 2020-07-06 21:39

(2) different approach

Step 1:
Create a table (in your SQL tool or by code) and populate id's 1-7 with your localized weekday names, starting with 1=Sunday...7=Saturday.

Code: Select all

DROP TABLE IF EXISTS `i18n_weekdays`;
CREATE TABLE `i18n_weekdays` (
  `id` int(11) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `weekdayname` varchar(20) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

INSERT INTO `i18n_weekdays` (`id`, `lang_code`, `weekdayname`) VALUES
(1,	'de',	'Sonntag'),
(2,	'de',	'Montag'),
(3,	'de',	'Dienstag'),
(4,	'de',	'Mittwoch'),
(5,	'de',	'Donnerstag'),
(6,	'de',	'Freitag'),
(7,	'de',	'Samstag');
Step 2:
Your calculated field SQL:

Code: Select all

SELECT `i18n_weekdays`.`weekdayname`
FROM `TABLENAME` INNER JOIN `i18n_weekdays` 
ON dayofweek(`TABLENAME`.`FIELDNAME`) = `i18n_weekdays`.`id` 
AND `i18n_weekdays`.`lang_code` = 'de'
WHERE `TABLENAME`.`PKFIELDNAME`='%ID%'
2nd approach is a bit more complicated but also more flexible for future purposes. If you only focus on one language, you do not even need the lang_code column but just id and name columns.

Regards,
Jan
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

lzonca
Posts: 16
Joined: 2019-03-11 14:48

Re: Day of Week problem Language

Post by lzonca » 2020-07-08 19:46

jsetzer wrote:
2020-07-06 21:15

Code: Select all

SELECT ELT(dayofweek(`FIELDNAME`), 'Dom', 'Lun', 'Mar', 'Mer', 'Gio', 'Ven', 'Sab')
FROM `TABLENAME` 
WHERE `PKCOLUMN`='%ID%' 
Please note that first entry in list of days is Sunday, because (by default) week starts on Sundays in MySQL databases.

Just replace:
  • FIELDNAME (your date field)
  • TABLENAME your table name
  • PKCOLUMN your primary key column name
In your specific case:

Code: Select all

SELECT ELT(dayofweek(`data_servizio`), 'Dom', 'Lun', 'Mar', 'Mer', 'Gio', 'Ven', 'Sab')
FROM `Servizi` 
WHERE `id_servizio`='%ID%' 


Great. Thanks, Solution 1 it works, but I only have one small problem. Eg (Mon = Monday) the problem is the accented letters, Monday = Monday? is it possible to solve this problem?

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: Day of Week problem Language

Post by jsetzer » 2020-07-08 21:17

Sorry, I do not understand.

You can change the resulting daynames to whatever you like, for example to strings having any international characters

Code: Select all

SELECT ELT(dayofweek(`date`), 'äöü', 'ÄÖÜ', 'ß', 'áà', 'â', 'Ææ', '♠♣♥♦')
FROM `vouchers` 
chrome_Gu9NviR1Hr.png
chrome_Gu9NviR1Hr.png (10.58 KiB) Viewed 3155 times

Just replace the 7 entries 'Dom', 'Lun', 'Mar', 'Mer', 'Gio', 'Ven', 'Sab' by any different seven entries, wrapped in single-quotes, each
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

lzonca
Posts: 16
Joined: 2019-03-11 14:48

Re: Day of Week problem Language

Post by lzonca » 2020-07-10 19:12

I'm sorry, I didn't explain myself well.
I'll explain it with screens
Attachments
Schermata 2020-07-10 alle 21.09.08.png
Schermata 2020-07-10 alle 21.09.08.png (112.2 KiB) Viewed 3115 times
Schermata 2020-07-10 alle 21.08.33.png
Schermata 2020-07-10 alle 21.08.33.png (33.01 KiB) Viewed 3115 times

Post Reply