Day of the week in other language

Hello all :) I have a Yun+bmp180 telling me the date an the temperature+ pressure on a LCD16x2.

Do some know if it's possible to get the day of the week (Monday,Tuesday,...) print in french? Usually use locale help, but there is none on the Yun. So now I use the English format.

Thanks to read my post and happy coding ;)

Alomamabobo: Hello all :) I have a Yun+bmp180 telling me the date an the temperature+ pressure on a LCD16x2.

Do some know if it's possible to get the day of the week (Monday,Tuesday,...) print in french? Usually use locale help, but there is none on the Yun. So now I use the English format.

Thanks to read my post and happy coding ;)

@Alomamabobo,

If you are not aware of this, the Yun OS is built on top of OpenWrt. It does not have an language (other than english) available in the default mode. To get French, you have several ways to do this

1) recompile the entire system from scratch. This might be too much work.

2) Patch your code to translate English to French.

3) Install a package that has French available, such as python library.

Lastly, could you please modify your Subject line to say: Day of the week, in French

TIA Jesse

Thanks for the reply :) Second solution seems ok to me but I dont have the required code skill :sob:

Rearranged from the Timecheck example:

// This function return a string with the time stamp
String getDateStamp() {
  String resultd;
  Process date;
  // date is a command line utility to get the date and the time
  // in different formats depending on the additional parameter
  date.begin("date");
  date.addParameter("+%A");  // parameters: http://www.cyberciti.biz/faq/linux-unix-formatting-dates-for-display/
  date.run();  // run the command
  // read the output of the command
  while (date.available() > 0) {
    char c = date.read();
    if (c != '\n')
      resultd += c;
  }
  return resultd;
}

So far I don't know how to translate a value in a string into an other.

Note: renamed the topic to a more comprehensive title.

Thank You.

Alomamabobo: So far I don't know how to translate a value in a string into an other.

You could do a series of string comparisons against the English day of the week string, and substitute the French word, but it would be easier with the day of the week numeric value:

// This function return a string with the time stamp
String getDateStamp() {
  String resultd;
  Process date;
  // date is a command line utility to get the date and the time
  // in different formats depending on the additional parameter
  date.begin("date");
  date.addParameter("+%w");  // parameters: http://www.cyberciti.biz/faq/linux-unix-formatting-dates-for-display/
  date.run();  // run the command
  // read the output of the command
  while (date.available() > 0) {
    char c = date.read();
    if (c != '\n')
      resultd += c;
  }

  switch (resultd.toInt())
  {
    case 0:  resultd = "Dimanche";   break;
    case 1:  resultd = "Lundi";      break;
and so on...
    case 0:  resultd = "Samdi";      break;
    default: resultd = "Inconnu";    break;
  }
  return resultd;
}

Of course, I did not compile or run that code...

Or, you could make a constant array with the days of the week as strings, and simply use the day of the week number as an index into that array (after adding range checking for a valid value.)

Thank You, will try this as soon as I come home. Tried, it works thanks :) Full code here if someone need it later :

// This function return a string with the time stamp
String getDateStamp() {
  String jour;
  Process date;
  // date is a command line utility to get the date and the time
  // in different formats depending on the additional parameter
  date.begin("date");
  date.addParameter("+%w");  // parameters: http://www.cyberciti.biz/faq/linux-unix-formatting-dates-for-display/
  date.run();  // run the command
  // read the output of the command
  while (date.available() > 0) {
    char c = date.read();
    if (c != '\n')
     jour += c;
   }
  switch (jour.toInt())
  {
    case 0:  jour = "Dimanche";   break;
    case 1:  jour = "Lundi";          break;
    case 2:  jour = "Mardi";          break;
    case 3:  jour = "Mercredi";     break;
    case 4:  jour = "Jeudi";          break;
    case 5:  jour = "Vendredi";     break;
    case 6:  jour = "Samedi";       break;
    default: resultd = "Inconnu";  break;
  }
  return jour;
}