Hi miika, Here are another four patches on the top of the previously sent patches. This is a try to make the HTML exports Multilingual I also fixed some bugs. I still need to update the user-manual if you find that these patches are good.
Thanks. On Fri, Aug 8, 2014 at 6:22 PM, Miika Turkia <miika.tur...@gmail.com> wrote: > On Fri, Aug 8, 2014 at 5:32 PM, Gehad Elrobey <gehadelro...@gmail.com> > wrote: > >> I have attached some patches that improves the statistics table view and >> fix the cells layout. >> >> Thanks, I'll take a look later. > >> >> >> On Mon, Aug 4, 2014 at 6:40 PM, Miika Turkia <miika.tur...@gmail.com> >> wrote: >> >>> Looking good, but some more improvements needed after a brief test: >>> >>> - When I export dives from one trip only, the trip mode sorting shows >>> all the exported dives under other. >>> >> >> I don't understand this, could you clarify that please? >> > > when I export one trip, and open the HTML, the trip mode does not show the > trip info. The attached screenshot will hopefully clarify. > > miika >
From c782f06f881dd59d6fd597fa441ee5d01e661736 Mon Sep 17 00:00:00 2001 From: Gehad elrobey <gehadelro...@gmail.com> Date: Sun, 10 Aug 2014 12:25:03 +0300 Subject: [PATCH 9/9] HTML: show translated words dyanmically from JSON translation file. Make HTML exports Multilingual by showing dynamically the HTML words from JSON files. The needed words are translated using the translation API in subsurface. Signed-off-by: Gehad elrobey <gehadelro...@gmail.com> --- theme/dive_export.html | 32 +++++++----- theme/list_lib.js | 135 +++++++++++++++++++++++++++++-------------------- 2 files changed, 100 insertions(+), 67 deletions(-) diff --git a/theme/dive_export.html b/theme/dive_export.html index 065a8a4..fd98ba4 100644 --- a/theme/dive_export.html +++ b/theme/dive_export.html @@ -39,6 +39,10 @@ function load_scripts() document.getElementsByTagName("head")[0].appendChild(fileref); fileref=document.createElement('script'); + fileref.setAttribute("src", location.pathname + "_files/translation.json"); + document.getElementsByTagName("head")[0].appendChild(fileref); + + fileref=document.createElement('script'); fileref.setAttribute("src", location.pathname + "_files/settings.json"); document.getElementsByTagName("head")[0].appendChild(fileref); @@ -127,6 +131,9 @@ window.onload=function(){ document.body.style.visibility='visible'; document.onkeydown = switchDives; + + //translate Page + translate_page(); } function changeAdvSearch(e){ @@ -145,7 +152,8 @@ function changeAdvSearch(e){ </center> <div id="diveListPanel"> <div id="controlbox"> - <input id="search_input" oninput="SearchModules(this.value, null)" placeholder="search"/><a id="adv_srch_sp" onClick="showdiv()" >Advanced Search</a> + <input id="search_input" oninput="SearchModules(this.value, null)" placeholder="search"/> + <a id="adv_srch_sp" onClick="showdiv()" >Advanced Search</a> <div id="advanced_search"> <input type="checkbox" onchange="changeAdvSearch(this)" value="location" checked>Location<br> <input type="checkbox" onchange="changeAdvSearch(this)" value="divemaster" checked>Divemaster<br> @@ -160,19 +168,19 @@ function changeAdvSearch(e){ <option>50</option> <option>100</option> </select> - <button onClick="expandAll()"> Expand All </button> - <button onClick="collapseAll()"> Collapse All </button> + <button id="expnd_all_btn" onClick="expandAll()"> Expand All </button> + <button id="claps_all_btn" onClick="collapseAll()"> Collapse All </button> <button id="trip_button" onclick="toggleTrips();">trips</button> <button id="stats_button" onclick="toggleStats();">Stats</button> </div> </div> <div id="header"> - <div onClick="change_sort_col('1')" class="item">Number</div> - <div onClick="change_sort_col('2')" class="item">Date</div> - <div onClick="change_sort_col('3')" class="item">Time</div> - <div onClick="change_sort_col('6')" class="item_large">Location</div> - <div onClick="change_sort_col('4')" class="item">Air Temp</div> - <div onClick="change_sort_col('5')" class="item">Water Temp</div> + <div id="number_header" onClick="change_sort_col('1')" class="item">Number</div> + <div id="date_header" onClick="change_sort_col('2')" class="item">Date</div> + <div id="time_header" onClick="change_sort_col('3')" class="item">Time</div> + <div id="location_header" onClick="change_sort_col('6')" class="item_large">Location</div> + <div id="air_temp_header" onClick="change_sort_col('4')" class="item">Air Temp</div> + <div id="water_temp_header" onClick="change_sort_col('5')" class="item">Water Temp</div> </div> <div id="diveslist"> </div> @@ -188,7 +196,7 @@ function changeAdvSearch(e){ <center> <div id="but"> <button onClick="prevDetailedDive()"><-</button> - <button onClick="unshowDiveDetails()">Back to List</button> + <button id="bk_to_ls_lbl" onClick="unshowDiveDetails()">Back to List</button> <button onClick="nextDetailedDive()">-></button> </div> </center> @@ -197,7 +205,7 @@ function changeAdvSearch(e){ <h2 id="dive_no"></h2> <h3 id="dive_location"></h3> </center> - <h2 class="det_hed">Dive profile</h2> + <h2 id="div_profil_lbl" class="det_hed">Dive profile</h2> <div style="width:100%" id="chart1"></div> </div> <div id="diveinfo"> @@ -224,7 +232,7 @@ function changeAdvSearch(e){ </div> <div id="diveStat"> <center> - <button onClick="toggleStats()">Back to List</button> + <button id="bk_to_ls_lbl2" onClick="toggleStats()">Back to List</button> </center> <div id="diveStatsData"> </div> diff --git a/theme/list_lib.js b/theme/list_lib.js index 089f8bf..8c2faca 100644 --- a/theme/list_lib.js +++ b/theme/list_lib.js @@ -126,7 +126,7 @@ function next_page() function view_pagging(start, end) { var page = document.getElementById("pagging"); - page.innerHTML = (start + 1) + ' to ' + (end + 1) + ' of ' + (itemsToShow.length) + ' dives'; + page.innerHTML = (start + 1) + ' to ' + (end + 1) + ' of ' + (itemsToShow.length) + '' + translate.dives; } /** @@ -134,12 +134,14 @@ function view_pagging(start, end) */ function expandAll() { + console.time('expnadAll'); for (var i = start; i < start + sizeofpage; i++) { if (i >= itemsToShow.length) break; unexpand(document.getElementById(itemsToShow[i])); items[itemsToShow[i]].expanded = false; } + console.timeEnd('expnadAll'); } /** @@ -204,22 +206,22 @@ function getlimited(dive) function getExpanded(dive) { - var res = '<table><tr><td class="words">Date: </td><td>' + dive.date + - '</td><td class="words"> Time: </td><td>' + dive.time + - '</td><td class="words"> Location: </td><td>' + '<a onclick=\"Search_list_Modules(\'' + dive.location + '\', {location:true, divemaster:false, buddy:false, notes:false, tags:false,})\">' + dive.location + '</a>' + - '</td></tr></table><table><tr><td class="words">Rating:</td><td>' + putRating(dive.rating) + - '</td><td class="words"> Visibilty:</td><td>' + putRating(dive.visibility) + + var res = '<table><tr><td class="words">' + translate.Date + ': </td><td>' + dive.date + + '</td><td class="words"> ' + translate.Time + ': </td><td>' + dive.time + + '</td><td class="words"> ' + translate.Locaiton + ': </td><td>' + '<a onclick=\"Search_list_Modules(\'' + dive.location + '\', {location:true, divemaster:false, buddy:false, notes:false, tags:false,})\">' + dive.location + '</a>' + + '</td></tr></table><table><tr><td class="words">' + translate.Rating + ':</td><td>' + putRating(dive.rating) + + '</td><td class="words"> ' + translate.Visibility + ':</td><td>' + putRating(dive.visibility) + '</td></tr></table>' + - '<table><tr><td class="words">Air temp: </td><td>' + dive.temperature.air + - '</td><td class="words"> Water temp: </td><td>' + dive.temperature.water + - '</td></tr></table><table><tr><td class="words">Duration: </td><td>' + dive.dive_duration + - '</td></tr><tr><td class="words">DiveMaster: </td><td>' + dive.divemaster + - '</td></tr><tr><td class="words"><p>Buddy: </p></td><td>' + dive.buddy + - '</td></tr><tr><td class="words">Suit: </td><td>' + dive.suit + - '</td></tr><tr><td class="words">Tags: </td><td>' + putTags(dive.tags) + - '</td></tr></table><div style="margin:10px;"><p class="words">Notes: </p>' + dive.notes + '</div>'; + '<table><tr><td class="words">' + translate.Air_Temp + ': </td><td>' + dive.temperature.air + + '</td><td class="words"> ' + translate.Water_Temp + ': </td><td>' + dive.temperature.water + + '</td></tr></table><table><tr><td class="words">' + translate.Duration + ': </td><td>' + dive.dive_duration + + '</td></tr><tr><td class="words">' + translate.DiveMaster + ': </td><td>' + dive.divemaster + + '</td></tr><tr><td class="words"><p>' + translate.Buddy + ': </p></td><td>' + dive.buddy + + '</td></tr><tr><td class="words">' + translate.Suit + ': </td><td>' + dive.suit + + '</td></tr><tr><td class="words">' + translate.Tags + ': </td><td>' + putTags(dive.tags) + + '</td></tr></table><div style="margin:10px;"><p class="words">' + translate.Notes + ': </p>' + dive.notes + '</div>'; if (settings.listOnly === '0') { - res += '<center><a onclick="showDiveDetails(' + dive.number + ')">Show more details</a></center>'; + res += '<center><a onclick="showDiveDetails(' + dive.number + ')">' + translate.Show_more_details + '</a></center>'; } return res; }; @@ -660,11 +662,11 @@ function toggleStats() if (statsShows) { statsShows = false; stats_button.style.backgroundColor = "#dfdfdf"; - document.getElementById('diveListPanel').style.display='block'; - document.getElementById('diveStat').style.display='none'; + document.getElementById('diveListPanel').style.display = 'block'; + document.getElementById('diveStat').style.display = 'none'; } else { - document.getElementById('diveListPanel').style.display='none'; - document.getElementById('diveStat').style.display='block'; + document.getElementById('diveListPanel').style.display = 'none'; + document.getElementById('diveStat').style.display = 'block'; stats_button.style.backgroundColor = "#5f7f8f"; statsShows = true; showStats(); @@ -677,29 +679,33 @@ function showStats() document.getElementById('diveStatsData').innerHTML += getDiveStats(); } -function getDiveStats(){ +function getDiveStats() +{ var res = ""; res += '<table><tr id="stats_header">'; - res += '<td class="statscell">Year</td><td class="statscell">#</td><td class="statscell">Total Time</td><td class="statscell">Average Time</td><td class="statscell">Shortest Time</td><td class="statscell">Longest Time</td><td class="statscell">Average Depth</td><td class="statscell">Min Depth</td><td class="statscell">Max Depth</td><td class="statscell">Average SAC</td><td class="statscell">Min SAC</td><td class="statscell">Max SAC</td><td class="statscell">Average Temp</td><td class="statscell">Min Temp</td><td class="statscell">Max Temp</td>'; + res += '<td class="statscell">' + translate.Year + '</td><td class="statscell">#</td><td class="statscell">' + translate.Total_Time + '</td><td class="statscell">' + translate.Average_Time + '</td><td class="statscell">' + translate.Shortest_Time + '</td><td class="statscell">' + translate.Longest_Time + '</td><td class="statscell">' + translate.Average_Depth + '</td><td class="statscell">' + translate.Min_Depth + '</td><td class="statscell">' + translate.Max_Depth + '</td><td class="statscell">' + translate.Average_SAC + '</td><td class="statscell">' + translate.Min_SAC + '</td><td class="statscell">' + translate.Max_SAC + '</td><td class="statscell">' + translate.Average_Temp + '</td><td class="statscell">' + translate.Min_Temp + '</td><td class="statscell">' + translate.Max_Temp + '</td>'; res += '</tr>'; res += getStatsRows(); res += '</table>'; return res; } -function getStatsRows(){ +function getStatsRows() +{ var res = ""; - for(var i = 0; i < divestat.length ; i++) { - res += '<tr onmouseout="stats_row_unhighlight(this)" onmouseover="stats_row_highlight(this)" class="stats_row"><td class="statscell">'+divestat[i].YEAR+'</td><td class="statscell">'+divestat[i].DIVES+'</td><td class="statscell">'+divestat[i].TOTAL_TIME+'</td><td class="statscell">'+divestat[i].AVERAGE_TIME+'</td><td class="statscell">'+divestat[i].SHORTEST_TIME+'</td><td class="statscell">'+divestat[i].LONGEST_TIME+'</td><td class="statscell">'+divestat[i].AVG_DEPTH+'</td><td class="statscell">'+divestat[i].MIN_DEPTH+'</td><td class="statscell">'+divestat[i].MAX_DEPTH+'</td><td class="statscell">'+divestat[i].AVG_SAC+'</td><td class="statscell">'+divestat[i].MIN_SAC+'</td><td class="statscell">'+divestat[i].MAX_SAC+'</td><td class="statscell">'+divestat[i].AVG_TEMP+'</td><td class="statscell">'+divestat[i].MIN_TEMP+'</td><td class="statscell">'+divestat[i].MAX_TEMP+'</td></tr>'; + for (var i = 0; i < divestat.length; i++) { + res += '<tr onmouseout="stats_row_unhighlight(this)" onmouseover="stats_row_highlight(this)" class="stats_row"><td class="statscell">' + divestat[i].YEAR + '</td><td class="statscell">' + divestat[i].DIVES + '</td><td class="statscell">' + divestat[i].TOTAL_TIME + '</td><td class="statscell">' + divestat[i].AVERAGE_TIME + '</td><td class="statscell">' + divestat[i].SHORTEST_TIME + '</td><td class="statscell">' + divestat[i].LONGEST_TIME + '</td><td class="statscell">' + divestat[i].AVG_DEPTH + '</td><td class="statscell">' + divestat[i].MIN_DEPTH + '</td><td class="statscell">' + divestat[i].MAX_DEPTH + '</td><td class="statscell">' + divestat[i].AVG_SAC + '</td><td class="statscell">' + divestat[i].MIN_SAC + '</td><td class="statscell">' + divestat[i].MAX_SAC + '</td><td class="statscell">' + divestat[i].AVG_TEMP + '</td><td class="statscell">' + divestat[i].MIN_TEMP + '</td><td class="statscell">' + divestat[i].MAX_TEMP + '</td></tr>'; } return res; } -function stats_row_highlight(row){ +function stats_row_highlight(row) +{ row.style.backgroundColor = "rgba(125,125,125,0.7)"; } -function stats_row_unhighlight(row){ +function stats_row_unhighlight(row) +{ row.style.backgroundColor = "rgba(125,125,125,0.3)"; } @@ -806,7 +812,7 @@ function get_weight_HTML(weight) function get_weights_HTML(dive) { var result = ""; - result += '<table><tr><td class="words">Weight</td><td class="words">Type</td></tr>'; + result += '<table><tr><td class="words">' + translate.Weight + '</td><td class="words">' + translate.Type + '</td></tr>'; for (var i in dive.Weights) { result += get_weight_HTML(dive.Weights[i]); } @@ -840,7 +846,7 @@ function get_cylinder_HTML(cylinder) function get_cylinders_HTML(dive) { var result = ""; - result += '<h2 class="det_hed">Dive equipments</h2><table><tr><td class="words">Type</td><td class="words">Size</td><td class="words">Work Pressure</td><td class="words">Start Pressure</td><td class="words">End Pressure</td><td class="words">O2</td></tr>'; + result += '<h2 class="det_hed">' + translate.Dive_equipments + '</h2><table><tr><td class="words">' + translate.Type + '</td><td class="words">' + translate.Size + '</td><td class="words">' + translate.Work_Pressure + '</td><td class="words">' + translate.Start_Pressure + '</td><td class="words">' + translate.End_Pressure + '</td><td class="words">O2</td></tr>'; for (var i in dive.Cylinders) { result += get_cylinder_HTML(dive.Cylinders[i]); } @@ -877,7 +883,7 @@ function get_bookmarks_HTML(dive) if (dive.events <= 0) return ""; var result = ""; - result += '<h2 class="det_hed">Events</h2><table><tr><td class="words">Name</td><td class="words">Time</td><td class="words">Value</td></tr>'; + result += '<h2 class="det_hed">' + translate.Events + '</h2><table><tr><td class="words">' + translate.Name + '</td><td class="words">' + translate.Time + '</td><td class="words">' + translate.Value + '</td></tr>'; for (var i in dive.events) { result += get_bookmark_HTML(dive.events[i]); } @@ -890,21 +896,21 @@ function get_bookmarks_HTML(dive) */ function get_dive_HTML(dive) { - return '<h2 class="det_hed">Dive Information</h2><table><tr><td class="words">Date: </td><td>' + dive.date + - '</td><td class="words"> Time: </td><td>' + dive.time + - '</td><td class="words"> Location: </td><td>' + '<a onclick=\"Search_list_Modules(\'' + dive.location + '\', {location:true, divemaster:false, buddy:false, notes:false, tags:false,})\">' + - dive.location + '</a>' + - '</td></tr></table><table><tr><td class="words">Rating:</td><td>' + putRating(dive.rating) + - '</td><td class="words"> Visibilty:</td><td>' + putRating(dive.visibility) + - '</td></tr></table>' + - '<table><tr><td class="words">Air temp: </td><td>' + dive.temperature.air + - '</td><td class="words"> Water temp: </td><td>' + dive.temperature.water + - '</td></tr></table><table><tr><td class="words">Duration: </td><td>' + dive.dive_duration + - '</td></tr><tr><td class="words">DiveMaster: </td><td>' + dive.divemaster + - '</td></tr><tr><td class="words"><p>Buddy: </p></td><td>' + dive.buddy + - '</td></tr><tr><td class="words">Suit: </td><td>' + dive.suit + - '</td></tr><tr><td class="words">Tags: </td><td>' + putTags(dive.tags) + - '</td></tr></table><div style="margin:10px;"><p class="words">Notes: </p>' + dive.notes + '</div>'; + var res = '<h2 class="det_hed">' + translate.Dive_information + '</h2><table><tr><td class="words">' + translate.Date + ': </td><td>' + dive.date + + '</td><td class="words"> ' + translate.Time + ': </td><td>' + dive.time + + '</td><td class="words"> ' + translate.Locaiton + ': </td><td>' + '<a onclick=\"Search_list_Modules(\'' + dive.location + '\', {location:true, divemaster:false, buddy:false, notes:false, tags:false,})\">' + dive.location + '</a>' + + '</td></tr></table><table><tr><td class="words">' + translate.Rating + ':</td><td>' + putRating(dive.rating) + + '</td><td class="words"> ' + translate.Visibility + ':</td><td>' + putRating(dive.visibility) + + '</td></tr></table>' + + '<table><tr><td class="words">' + translate.Air_Temp + ': </td><td>' + dive.temperature.air + + '</td><td class="words"> ' + translate.Water_Temp + ': </td><td>' + dive.temperature.water + + '</td></tr></table><table><tr><td class="words">' + translate.Duration + ': </td><td>' + dive.dive_duration + + '</td></tr><tr><td class="words">' + translate.DiveMaster + ': </td><td>' + dive.divemaster + + '</td></tr><tr><td class="words"><p>' + translate.Buddy + ': </p></td><td>' + dive.buddy + + '</td></tr><tr><td class="words">' + translate.Suit + ': </td><td>' + dive.suit + + '</td></tr><tr><td class="words">' + translate.Tags + ': </td><td>' + putTags(dive.tags) + + '</td></tr></table><div style="margin:10px;"><p class="words">' + translate.Notes + ': </p>' + dive.notes + '</div>'; + return res; }; /** @@ -912,10 +918,9 @@ function get_dive_HTML(dive) */ function get_status_HTML(dive) { - return '<h2 class="det_hed">Dive Status</h2><table><tr><td class="words">Sac: </td><td>' + ml_to_litre(dive.sac) + + return '<h2 class="det_hed">' + translate.Dive_Status + '</h2><table><tr><td class="words">Sac: </td><td>' + ml_to_litre(dive.sac) + ' l/min' + '</td><td class="words"> Otu: </td><td>' + dive.otu + - '</td><td class="words"> Cns: </td><td>' + dive.cns + - '</td></tr></table>'; + '</td><td class="words"> Cns: </td><td>' + dive.cns + '</td></tr></table>'; }; function get_dive_photos(dive) @@ -927,8 +932,8 @@ function get_dive_photos(dive) var slider = ""; document.getElementById("divephotos").style.display = 'block'; for (var i = 0; i < dive.photos.length; i++) { - slider += '<img src="'+location.pathname + - '_files/photos/'+dive.photos[i].filename+'" alt="" height="240" width="240">'; + slider += '<img src="' + location.pathname + + '_files/photos/' + dive.photos[i].filename + '" alt="" height="240" width="240">'; } return slider; } @@ -1034,8 +1039,7 @@ function canvas_draw() 0 ]); } - if (plot1) - { + if (plot1) { $('chart1').unbind(); plot1.destroy(); } @@ -1166,7 +1170,7 @@ function showDiveDetails(dive) function setDiveTitle(dive) { - document.getElementById("dive_no").innerHTML = "Dive No. " + (settings.subsurfaceNumbers === '0' ? + document.getElementById("dive_no").innerHTML = translate.Dive_No + (settings.subsurfaceNumbers === '0' ? dive.number + 1 : dive.subsurface_number); document.getElementById("dive_location").innerHTML = dive.location; } @@ -1214,7 +1218,28 @@ function switchDives(e) } } -window.onresize = function(event) { - if (plot1) - plot1.replot( { resetAxes: true } ); +window.onresize = function(event) +{ + if (plot1) + plot1.replot({ + resetAxes : true + }); }; + +function translate_page() +{ + document.getElementById("number_header").innerHTML = translate.Number; + document.getElementById("date_header").innerHTML = translate.Date; + document.getElementById("time_header").innerHTML = translate.Time; + document.getElementById("location_header").innerHTML = translate.Locaiton; + document.getElementById("air_temp_header").innerHTML = translate.Air_Temp; + document.getElementById("water_temp_header").innerHTML = translate.Water_Temp; + document.getElementById("adv_srch_sp").innerHTML = translate.Advanced_Search; + document.getElementById("expnd_all_btn").innerHTML = translate.Expand_All; + document.getElementById("claps_all_btn").innerHTML = translate.Collapse_All; + document.getElementById("trip_button").innerHTML = translate.trips; + document.getElementById("stats_button").innerHTML = translate.Statistics; + document.getElementById("div_profil_lbl").innerHTML = translate.Dive_profile; + document.getElementById("bk_to_ls_lbl").innerHTML = translate.Back_to_List; + document.getElementById("bk_to_ls_lbl2").innerHTML = translate.Back_to_List; +} -- 1.9.1
From 74699b0f2b1e2e9fccb468d073b8b16fa4923149 Mon Sep 17 00:00:00 2001 From: Gehad elrobey <gehadelro...@gmail.com> Date: Sun, 10 Aug 2014 10:12:29 +0300 Subject: [PATCH 8/9] HTML: export Translated strings to JSON files. First step towards multilingual export. Use the existing translation API to translate and save words to JSON file. Signed-off-by: Gehad elrobey <gehadelro...@gmail.com> --- qt-ui/divelogexportdialog.cpp | 2 ++ save-html.c | 81 +++++++++++++++++++++++++++++++++++++++++++ save-html.h | 1 + 3 files changed, 84 insertions(+) diff --git a/qt-ui/divelogexportdialog.cpp b/qt-ui/divelogexportdialog.cpp index 9ea2030..99669d6 100644 --- a/qt-ui/divelogexportdialog.cpp +++ b/qt-ui/divelogexportdialog.cpp @@ -95,6 +95,7 @@ void DiveLogExportDialog::exportHtmlInit(const QString &filename) QString json_dive_data = exportFiles + QDir::separator() + "file.json"; QString json_settings = exportFiles + QDir::separator() + "settings.json"; + QString translation = exportFiles + QDir::separator() + "translation.json"; QString stat_file = exportFiles + QDir::separator() + "stat.json"; QString photos_directory = exportFiles + QDir::separator() + "photos" + QDir::separator(); mainDir.mkdir(photos_directory); @@ -102,6 +103,7 @@ void DiveLogExportDialog::exportHtmlInit(const QString &filename) exportHTMLsettings(json_settings); exportHTMLstatistics(stat_file); + export_translation(translation.toUtf8().data()); export_HTML(json_dive_data.toUtf8().data(), photos_directory.toUtf8().data(), ui->exportSelectedDives->isChecked(), ui->exportListOnly->isChecked()); diff --git a/save-html.c b/save-html.c index 6190c36..150ee3c 100644 --- a/save-html.c +++ b/save-html.c @@ -324,3 +324,84 @@ void export_HTML(const char *file_name, const char *photos_dir, const bool selec free_buffer(&buf); fclose(f); } + +void export_translation(const char *file_name){ + FILE *f; + + struct membuffer buf = { 0 }; + struct membuffer *b = &buf; + + //export translated words here + put_format(b, "translate={"); + + //Dive list view + write_attribute(b, "Number", translate("gettextFromC", "Number")); + write_attribute(b, "Date", translate("gettextFromC", "Date")); + write_attribute(b, "Time", translate("gettextFromC", "Time")); + write_attribute(b, "Locaiton", translate("gettextFromC", "Locaiton")); + write_attribute(b, "Air_Temp", translate("gettextFromC", "Air Temp")); + write_attribute(b, "Water_Temp", translate("gettextFromC", "Water Temp")); + write_attribute(b, "dives", translate("gettextFromC", "dives")); + write_attribute(b, "Expand_All", translate("gettextFromC", "Expand All")); + write_attribute(b, "Collapse_All", translate("gettextFromC", "Collapse All")); + write_attribute(b, "trips", translate("gettextFromC", "trips")); + write_attribute(b, "Statistics", translate("gettextFromC", "Statistics")); + write_attribute(b, "Advanced_Search", translate("gettextFromC", "Advanced Search")); + + //Dive expanded view + write_attribute(b, "Rating", translate("gettextFromC", "Rating")); + write_attribute(b, "Visibility", translate("gettextFromC", "Visibility")); + write_attribute(b, "Duration", translate("gettextFromC", "Duration")); + write_attribute(b, "DiveMaster", translate("gettextFromC", "DiveMaster")); + write_attribute(b, "Buddy", translate("gettextFromC", "Buddy")); + write_attribute(b, "Suit", translate("gettextFromC", "Suit")); + write_attribute(b, "Tags", translate("gettextFromC", "Tags")); + write_attribute(b, "Notes", translate("gettextFromC", "Notes")); + write_attribute(b, "Show_more_details", translate("gettextFromC", "Show more details")); + + //Yearly statistics view + write_attribute(b, "Yearly_statistics", translate("gettextFromC", "Yearly statistics")); + write_attribute(b, "Year", translate("gettextFromC", "Year")); + write_attribute(b, "Total_Time", translate("gettextFromC", "Total Time")); + write_attribute(b, "Average_Time", translate("gettextFromC", "Average Time")); + write_attribute(b, "Shortest_Time", translate("gettextFromC", "Shortest Time")); + write_attribute(b, "Longest_Time", translate("gettextFromC", "Longest Time")); + write_attribute(b, "Average_Depth", translate("gettextFromC", "Average Depth")); + write_attribute(b, "Min_Depth", translate("gettextFromC", "Min Depth")); + write_attribute(b, "Max_Depth", translate("gettextFromC", "Max Depth")); + write_attribute(b, "Average_SAC", translate("gettextFromC", "Average SAC")); + write_attribute(b, "Min_SAC", translate("gettextFromC", "Min SAC")); + write_attribute(b, "Max_SAC", translate("gettextFromC", "Max SAC")); + write_attribute(b, "Average_Temp", translate("gettextFromC", "Average Temp")); + write_attribute(b, "Min_Temp", translate("gettextFromC", "Min Temp")); + write_attribute(b, "Max_Temp", translate("gettextFromC", "Max Temp")); + write_attribute(b, "Back_to_List", translate("gettextFromC", "Back to List")); + + //dive detailed view + write_attribute(b, "Dive_No", translate("gettextFromC", "Dive No.")); + write_attribute(b, "Dive_profile", translate("gettextFromC", "Dive profile")); + write_attribute(b, "Dive_information", translate("gettextFromC", "Dive information")); + write_attribute(b, "Dive_equipments", translate("gettextFromC", "Dive equipments")); + write_attribute(b, "Type", translate("gettextFromC", "Type")); + write_attribute(b, "Size", translate("gettextFromC", "Size")); + write_attribute(b, "Work_Pressure", translate("gettextFromC", "Work Pressure")); + write_attribute(b, "Start_Pressure", translate("gettextFromC", "Start Pressure")); + write_attribute(b, "End_Pressure", translate("gettextFromC", "End Pressure")); + write_attribute(b, "Weight", translate("gettextFromC", "Weight")); + write_attribute(b, "Type", translate("gettextFromC", "Type")); + write_attribute(b, "Events", translate("gettextFromC", "Events")); + write_attribute(b, "Name", translate("gettextFromC", "Name")); + write_attribute(b, "Value", translate("gettextFromC", "Value")); + + write_attribute(b, "Dive_Status", translate("gettextFromC", "Dive Status")); + + put_format(b, "}"); + + f = subsurface_fopen(file_name, "w+"); + if (!f) + report_error(translate("gettextFromC", "Can't open file %s"), file_name); + + flush_buffer(&buf, f); /*check for writing errors? */ + free_buffer(&buf); + fclose(f); +} diff --git a/save-html.h b/save-html.h index 2981961..bcf69d5 100644 --- a/save-html.h +++ b/save-html.h @@ -16,6 +16,7 @@ void put_HTML_notes(struct membuffer *b, struct dive *dive, const char *pre, con void put_HTML_quoted(struct membuffer *b, const char *text); void export_HTML(const char *file_name, const char *photos_dir, const bool selected_only, const bool list_only); +void export_translation(const char *file_name); extern void copy_image_and_overwrite(const char *cfileName, const char *cnewName); extern const char* get_file_name(const char *fileName); -- 1.9.1
From 995ccf1df3f9143c22f7892701d4696062a20e77 Mon Sep 17 00:00:00 2001 From: Gehad elrobey <gehadelro...@gmail.com> Date: Sun, 10 Aug 2014 07:10:41 +0300 Subject: [PATCH 7/9] HTML: Don't export total statistics value if not choosed Don't export total row in yearly statistics unless exporting the statistics is checked Signed-off-by: Gehad elrobey <gehadelro...@gmail.com> --- qt-ui/divelogexportdialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qt-ui/divelogexportdialog.cpp b/qt-ui/divelogexportdialog.cpp index f3f3294..9ea2030 100644 --- a/qt-ui/divelogexportdialog.cpp +++ b/qt-ui/divelogexportdialog.cpp @@ -182,8 +182,8 @@ void DiveLogExportDialog::exportHTMLstatistics(const QString &filename) total_stats.total_time.seconds += stats_yearly[i].total_time.seconds; i++; } + exportHTMLstatisticsTotal(out, &total_stats); } - exportHTMLstatisticsTotal(out, &total_stats); out << "]"; file.close(); } -- 1.9.1
From 7d00b60ead6dc7ce12ebc48ffb5d8d4f3712900d Mon Sep 17 00:00:00 2001 From: Gehad elrobey <gehadelro...@gmail.com> Date: Sun, 10 Aug 2014 07:10:19 +0300 Subject: [PATCH 6/9] HTML: Remember General Export Settings. Set Default values and remember user selected general HTML export settings. Signed-off-by: Gehad elrobey <gehadelro...@gmail.com> --- qt-ui/divelogexportdialog.cpp | 12 ++++++++++++ qt-ui/divelogexportdialog.ui | 6 ++++++ 2 files changed, 18 insertions(+) diff --git a/qt-ui/divelogexportdialog.cpp b/qt-ui/divelogexportdialog.cpp index 9156f17..f3f3294 100644 --- a/qt-ui/divelogexportdialog.cpp +++ b/qt-ui/divelogexportdialog.cpp @@ -45,6 +45,15 @@ DiveLogExportDialog::DiveLogExportDialog(QWidget *parent) : QDialog(parent), if (settings.contains("themeSelection")) { ui->themeSelection->setCurrentIndex(settings.value("themeSelection").toInt()); } + if (settings.contains("subsurfaceNumbers")) { + ui->exportSubsurfaceNumber->setChecked(settings.value("subsurfaceNumbers").toBool()); + } + if (settings.contains("yearlyStatistics")) { + ui->exportStatistics->setChecked(settings.value("yearlyStatistics").toBool()); + } + if (settings.contains("listOnly")) { + ui->exportListOnly->setChecked(settings.value("listOnly").toBool()); + } settings.endGroup(); } @@ -122,6 +131,9 @@ void DiveLogExportDialog::exportHTMLsettings(const QString &filename) settings.setValue("fontSelection", ui->fontSelection->currentIndex()); settings.setValue("fontSizeSelection", ui->fontSizeSelection->currentIndex()); settings.setValue("themeSelection", ui->themeSelection->currentIndex()); + settings.setValue("subsurfaceNumbers", ui->exportSubsurfaceNumber->isChecked()); + settings.setValue("yearlyStatistics", ui->exportStatistics->isChecked()); + settings.setValue("listOnly", ui->exportListOnly->isChecked()); settings.endGroup(); QString fontSize = ui->fontSizeSelection->currentText(); diff --git a/qt-ui/divelogexportdialog.ui b/qt-ui/divelogexportdialog.ui index 0e8ef4a..ce1513e 100644 --- a/qt-ui/divelogexportdialog.ui +++ b/qt-ui/divelogexportdialog.ui @@ -194,6 +194,9 @@ <property name="text"> <string>Subsurface numbers</string> </property> + <property name="checked"> + <bool>true</bool> + </property> </widget> </item> <item row="0" column="1"> @@ -220,6 +223,9 @@ <property name="text"> <string>Export Yearly Statistics</string> </property> + <property name="checked"> + <bool>true</bool> + </property> </widget> </item> <item row="1" column="1"> -- 1.9.1
_______________________________________________ subsurface mailing list subsurface@hohndel.org http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface