Skip to content

Commit

Permalink
Initial work on making text translatable
Browse files Browse the repository at this point in the history
  • Loading branch information
donovan6000 committed Oct 27, 2016
1 parent 644ff77 commit d7efb07
Show file tree
Hide file tree
Showing 19 changed files with 407 additions and 85 deletions.
22 changes: 22 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# This file is for unifying the coding style for different editors and IDEs
# editorconfig.org

root = true

[*]
end_of_line = lf
charset = utf-8
insert_final_newline = true
trim_trailing_whitespace = true

[**.py]
indent_style = tab

[**.js]
indent_style = tab

[**.h]
indent_style = tab

[**.cpp]
indent_style = tab
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
*.pyc
*.swp
.idea
*.iml
build
dist
*.egg*
.DS_Store
*.zip
1 change: 1 addition & 0 deletions Changelog
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Changelog:
V1.11 October X, 2016

* Heatbed will start heating up after moving extruder into the wipe corner
* Text can be translated into different languages

V1.10 October 25, 2016

Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include README.md
6 changes: 6 additions & 0 deletions babel.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[python: */**.py]
[jinja2: */**.jinja2]
extensions=jinja2.ext.autoescape, jinja2.ext.with_

[javascript: */**.js]
extract_messages = gettext, ngettext
3 changes: 2 additions & 1 deletion octoprint_m33fio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import yaml
import logging
import logging.handlers
from flask.ext.babel import gettext
from .gcode import Gcode
from .vector import Vector

Expand Down Expand Up @@ -1043,7 +1044,7 @@ def startWebcamProcess(self) :
octoprint.settings.settings().save()

# Send message
self._plugin_manager.send_plugin_message(self._identifier, dict(value = "Show Message", message = "Hosting camera failed", header = "Camera Host Status", confirm = True))
self._plugin_manager.send_plugin_message(self._identifier, dict(value = "Show Message", message = gettext("Hosting camera failed"), header = gettext("Camera Host Status"), confirm = True))

# Load shared library
def loadSharedLibrary(self, isUsable = False) :
Expand Down
83 changes: 62 additions & 21 deletions octoprint_m33fio/static/css/m33fio.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,34 +20,43 @@ body > div.modal-scrollable.hideOverflow {
}

#gcode div.midPrintFilamentChange label {
display: inline;
display: inline-flex;
width: calc(100% - 170px);
margin-bottom: 0;
}

#gcode div.midPrintFilamentChange button {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}

#gcode div.midPrintFilamentChange label input {
display: inline;
width: calc(100% - 197px);
position: relative;
top: 4px;
top: -5px;
margin-left: 5px;
margin-right: 5px;
flex-grow: 1;
}

#gcode div.midPrintFilamentChange button:first-of-type {
display: inline;
width: 140px;
width: 165px;
position: relative;
top: -1px;
}

#gcode div.midPrintFilamentChange button:nth-of-type(2) {
float: left;
width: 30%;
width: 35%;
margin-left: 70px;
}

#gcode div.midPrintFilamentChange button:nth-of-type(3) {
float: right;
width: 30%;
width: 35%;
margin-right: 70px;
}

Expand Down Expand Up @@ -257,13 +266,25 @@ body > div.modal-scrollable.hideOverflow {

#control div.jog-panel.extruder > div > div:first-of-type.show {
display: block !important;
width: 157px;
}

#control div.jog-panel.extruder > div > div:first-of-type.show > button {
overflow: hidden;
text-overflow: ellipsis;
}

#control div.jog-panel.extruder > div > div:first-of-type.show ul.dropdown-menu {
min-width: auto;
width: calc(100% - 2px);
}

#control div.jog-panel.extruder > div > div:first-of-type.show ul.dropdown-menu a {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}

#control div.jog-panel.extruder > div > div:first-of-type > button {
width: 100%;
}
Expand Down Expand Up @@ -315,31 +336,22 @@ body > div.modal-scrollable.hideOverflow {
}

#control div.jog-panel.extruder > div div.slider {
width: 125px !important;
position: relative;
right: 1px;
width: 141px !important;
}

#control div.jog-panel.extruder > div div.slider .slider-handle {
margin-left: -8px;
}

#control div.jog-panel.extruder > div > div > input {
width: 94px !important;
width: 109px !important;
}

#control div.jog-panel.general button {
width: 110px !important;
}

#control div.jog-panel.filament {
clear: left;
}

#control div.jog-panel.filament button {
width: 125px;
}

#control div.jog-panel.calibration button {
width: 180px;
float: left;
Expand Down Expand Up @@ -404,10 +416,6 @@ body > div.modal-scrollable.hideOverflow {
top: 0px;
}

#control div.jog-panel.advanced button {
width: 175px;
}

#control div.jog-panel.advanced button > img {
width: 23px;
height: 23px;
Expand Down Expand Up @@ -440,7 +448,6 @@ body > div.modal-scrollable.hideOverflow {
}

#control div.jog-panel.eeprom button {
width: 150px;
margin: 3px 5px 10px 5px;
display: inline-block;
}
Expand Down Expand Up @@ -1541,6 +1548,40 @@ body > div.page-container > div.message > div > div > span.show {
padding-bottom: 10px;
}

#control button.btn.btn-block {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}

#control div.jog-panel.controls button.btn.btn-block {
width: 169px;
}

#control div.jog-panel.extruder button.btn.btn-block {
width: 157px;
}

#control div.jog-panel.general button.btn.btn-block {
width: 140px;
}

#control div.jog-panel.filament button.btn.btn-block {
width: 125px;
}

#control div.jog-panel.advanced button.btn.btn-block {
width: 175px;
}

#control div.jog-panel.advanced button.btn.btn-block.firmware {
white-space: normal;
}

#control div.jog-panel.eeprom button.btn.btn-block{
width: 150px;
}

#temperature-graph {
transition: background-image 0.3s ease-out;
}
Expand Down
12 changes: 6 additions & 6 deletions octoprint_m33fio/static/js/m33fio.js
Original file line number Diff line number Diff line change
Expand Up @@ -14073,7 +14073,7 @@ $(function() {

// Otherwise check if data is to show message
else if(data.value == "Show Message" && typeof data.message !== "undefined" && typeof data.header !== "undefined") {

// Check if failed to connect and callback is set
if(data.header == "Connection Status" && typeof failedToConnectCallback === "function") {

Expand All @@ -14092,7 +14092,7 @@ $(function() {
else {

// Initialize variables
var text = htmlEncode(data.message);
var text = htmlEncode(gettext(data.message));

// Check if same text is currently being displayed
if($("body > div.page-container > div.message").hasClass("show") && $("body > div.page-container > div.message").find("p").eq(0).html() == text)
Expand All @@ -14113,7 +14113,7 @@ $(function() {
if(typeof data.confirm !== "undefined") {

// Display message
showMessage(htmlEncode(data.header), text, "OK", function() {
showMessage(htmlEncode(gettext(data.header)), text, gettext("OK"), function() {

// Hide message
hideMessage();
Expand All @@ -14124,7 +14124,7 @@ $(function() {
else

// Display message
showMessage(htmlEncode(data.header), text);
showMessage(htmlEncode(gettext(data.header)), text);
}
}

Expand Down Expand Up @@ -14849,7 +14849,7 @@ $(function() {

// On startup complete
self.onStartupComplete = function() {

// Add titles to buttons that weren't loaded before
$("#control div.jog-panel.controls > div > button:first-of-type, #control div.jog-panel.controls #control-jog-feedrate > button:first-of-type").attr("title", "Sets feed rate to the specified amount");
$("#control div.jog-panel.extruder > div > button:nth-of-type(3)").attr("title", "Sets flow rate to the specified amount");
Expand Down Expand Up @@ -15045,7 +15045,7 @@ $(function() {
self.onEventError = function(payload) {

// Check if using an Micro 3D printer and error is an unhandled firmware or communication error
if(!self.settings.settings.plugins.m33fio.NotUsingAMicro3DPrinter() && ($("div.ui-pnotify:last-of-type h4.ui-pnotify-title").text() == "Unhandled firmware error" || $("div.ui-pnotify:last-of-type h4.ui-pnotify-title").text() == "Unhandled communication error"))
if(!self.settings.settings.plugins.m33fio.NotUsingAMicro3DPrinter() && ($("div.ui-pnotify:last-of-type h4.ui-pnotify-title").text() == gettext("Unhandled firmware error") || $("div.ui-pnotify:last-of-type h4.ui-pnotify-title").text() == gettext("Unhandled communication error")))

// Remove error
$("div.ui-pnotify:last-of-type").remove();
Expand Down
4 changes: 2 additions & 2 deletions octoprint_m33fio/templates/m33fio_navbar.jinja2
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<select>
<option value="new" disabled>New</option>
<option value="close" disabled>Close</option>
<option value="new" disabled>{{_("New")}}</option>
<option value="close" disabled>{{_("Close")}}</option>
</select>
<a></a>
2 changes: 1 addition & 1 deletion octoprint_m33fio/templates/m33fio_settings.jinja2
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<form class="form-horizontal">
<div class="control-group title">
<h4>General</h4>
<h4>{{_("General")}}</h4>
</div>
<div class="control-group">
<div class="controls">
Expand Down
Binary file not shown.
58 changes: 58 additions & 0 deletions octoprint_m33fio/translations/de/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# German translations for OctoPrint-M33Fio.
# Copyright (C) 2016 The OctoPrint Project
# This file is distributed under the same license as the OctoPrint-M33Fio
# project.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2016.
#
msgid ""
msgstr ""
"Project-Id-Version: OctoPrint-M33Fio 1.10.2016102705\n"
"Report-Msgid-Bugs-To: i18n@octoprint.org\n"
"POT-Creation-Date: 2016-10-27 07:11-0700\n"
"PO-Revision-Date: 2016-10-27 05:45-0700\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: de\n"
"Language-Team: de <LL@li.org>\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.3.4\n"

#: octoprint_m33fio/__init__.py:1047
msgid "Hosting camera failed"
msgstr ""

#: octoprint_m33fio/__init__.py:1047
msgid "Camera Host Status"
msgstr ""

#: octoprint_m33fio/static/js/m33fio.js:5385
#: octoprint_m33fio/static/js/m33fio.js:5413
msgid "This will restart the print job from the beginning."
msgstr ""

#: octoprint_m33fio/static/js/m33fio.js:14116
msgid "OK"
msgstr ""

#: octoprint_m33fio/static/js/m33fio.js:15048
msgid "Unhandled firmware error"
msgstr ""

#: octoprint_m33fio/static/js/m33fio.js:15048
msgid "Unhandled communication error"
msgstr ""

#: octoprint_m33fio/templates/m33fio_navbar.jinja2:2
msgid "New"
msgstr ""

#: octoprint_m33fio/templates/m33fio_navbar.jinja2:3
msgid "Close"
msgstr ""

#: octoprint_m33fio/templates/m33fio_settings.jinja2:3
msgid "General"
msgstr ""

6 changes: 6 additions & 0 deletions push.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ fi
find ./ -name '*~' -print0 | xargs -0 rm
find ./ -name '*.pyc' -print0 | xargs -0 rm

# Update bundled translations
python setup.py babel_refresh
pybabel compile -d translations
python setup.py babel_bundle --locale=
find "octoprint_m33fio/translations" -maxdepth 1 -type f -delete

# Push changes
git add .
git commit -m "$3"
Expand Down
9 changes: 9 additions & 0 deletions requirements.txt
100755 → 100644
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
###
# This file is only here to make sure that something like
#
# pip install -e .
#
# works as expected. Requirements can be found in setup.py.
###

.
Loading

0 comments on commit d7efb07

Please sign in to comment.