diff --git a/Astrogator.version b/Astrogator.version index 461f0d1..00bbea8 100644 --- a/Astrogator.version +++ b/Astrogator.version @@ -9,18 +9,18 @@ }, "VERSION": { "MAJOR": 0, - "MINOR": 6, - "PATCH": 2, + "MINOR": 7, + "PATCH": 0, "BUILD": 0 }, "KSP_VERSION_MIN": { "MAJOR": 1, - "MINOR": 2, - "PATCH": 2 + "MINOR": 3, + "PATCH": 0 }, "KSP_VERSION_MAX": { "MAJOR": 1, - "MINOR": 2, - "PATCH": 99 + "MINOR": 3, + "PATCH": 8 } } diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3987285..d0ce884 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,6 +1,123 @@ # Contributing to Astrogator -Astrogator welcomes contributions from anyone in the form of problem reports, enhancement suggestions, and code changes. To make them as useful as possible, it's necessary to spell out some expectations. +Astrogator welcomes contributions from anyone in the form of translations, problem reports, enhancement suggestions, and code changes. To make them as useful as possible, it's necessary to spell out some expectations. + +## Translating to your language + +![Languages supported by KSP 1.3: English, Spanish, Chinese, Russian, Japanese](https://i.imgur.com/DbCCJWK.png) + +The 1.3 release of KSP introduces localization, which allows in-game text to be translated to other languages. This allows more people to enjoy the game in their preferred language and enlarges the community. However, it does not happen automatically for mods; by default, a mod will appear in English regardless of the language of the base game. In order to have both the base game and mods available in the same non-English languages, some additional work must be done by the modder. + +Unfortunately, I only speak English, and I maintain this mod for free. This means I cannot create my own translations, and I cannot pay a professional translation service to produce high quality translations. The best I can do on my own is to use Google Translate, which is of dubious value for the terse, idiomatic strings needed in a KSP mod's UI. Instead, I must rely on the expertise of you, the multilingual KSP mod user, to tell me what good translations look like for your language. If you would like to help in this effort, please keep reading to learn how the mod's language files are structured and how to submit translations for use by others. + +Note: Even though you will appear to be editing the project's files, don't worry about making mistakes. Github will keep your changes separate from the main files until I have verified that they are OK to use. It is even possible for me to ask questions or request changes before your work is committed to the main files. + +### Creating or editing a translation + +It is recommended to make your changes on your own computer at first so you can test them before uploading, especially if you are creating a new translation from scratch. + +1. Install the [current release of Astrogator](https://github.com/HebaruSan/Astrogator/releases/latest) if you have not already +2. Open your `Kerbal Space Program/GameData/Astrogator/lang` folder on your local disk +3. Look for a file called *lang*.cfg, where *lang* is KSP's name for your locale; as of KSP 1.3, this includes: + - en-us (English) + - es-es (Spanish) + - ja (Japanese) + - ru (Russian) + - zh-cn (Chinese) + +The remaining steps are different depending on whether the file already exists: + +#### If the file exists + +Follow these steps to make improvements to an existing translation: + +3. Edit the file for your language in your favorite text editor +4. Make the changes you wish to see in-game (see the [File format section](#file-format) below for details) +5. Save your changes +6. Remember to [test your changes](#testing)! + +#### If the file does not exist + +Follow these steps to start your own translation from scratch: + +3. Make a copy of `en-us.cfg` in the `lang` folder +4. Rename the file according to the list of languages above +5. Edit the file for your language in your favorite text editor +6. Change the third line from `en-us` to the string for your language +7. Translate each string from English to your language (see the [File format section](#file-format) below for details) +8. Save your changes +9. Remember to [test your changes](#testing)! + +#### File format + +The middle part of the `cfg` file contains the strings to translate. The format is `name = translation`, where the name is a special string defined by the mod. For example: + + astrogator_launchSubtitle = Transfers from <>\n(Launch ~<<2>>) + +Do **not** change the part to the left of the equals sign ("=")! These names must be the same in every language file. + +The part to the right of the equals sign is the string to be used in-game. Most of the text will be shown as-is, but it can contain a few special strings as shown in the [Lingoona grammar module demo](http://lingoona.com/cgi-bin/grammar#l=en): + +| String | Purpose | +| --- | --- | +| \n | Line break; try to preserve these based on the original strings to make sure the strings will fit | +| <<1>> | The first substitutable token in the string, will be replaced by a number, name of a planet, etc., depending on the string | +| <<2>> | Second token, and so on | +| <> | The first token, but substituted with a proper article | + +For example, this is a possible translation of the above line into Spanish, courtesy of Google Translate: + + astrogator_launchSubtitle = Transferencias de <>\n(Lanzamiento ~<<2>>) + +#### Testing + +It's important to make sure that your changes work correctly. If you use Steam: + +1. [Select the language to use in Steam](https://www.youtube.com/watch?v=iBwYCvQxfeI) +2. Wait for the language pack download to complete +3. Run KSP +4. Use Astrogator and make sure your changes appear as you intended + +If you do not use Steam, I don't know the steps to choose a language. Contact SQUAD if you can't figure it out. + +### Contributing your translation for others to use + +After you have prepared a `cfg` file for your language and confirmed that it works as you intend, if you are willing to contribute it for redistribution under the GLPv3 license, follow these steps to upload it for inclusion in the main mod distribution: + +1. Log in to [Github](https://github.com); you may need to register an account if you do not already have one +2. Navigate to the [lang folder](https://github.com/HebaruSan/Astrogator/tree/master/assets/lang) +3. Look for the file you edited + +The remaining steps are different depending on whether the file already exists: + +#### If the file exists + +4. Click the file's name to view it +5. Click the [pencil icon](https://help.github.com/assets/images/help/repository/edit-file-edit-button.png) to edit +6. Replace the text with the pasted contents of the file you edited locally +7. **Important**: At the bottom of the page, under Propose file change, type an English description of the changes you have made and the reason you think they should be made. This will help me to confirm that your changes are appropriate. Remember, I do not speak the language in the `cfg` file, so I need you to tell me why your way is better! +6. Click `Propose file change` at the bottom when done + +#### If the file does not exist + +4. Click [Create new file](https://help.github.com/assets/images/help/repository/create_new_file.png) to create it +5. Enter the correct file name in the box at the top +6. Paste the contents of the file you edited locally into the big box in the middle +8. Click `Propose new file` at the bottom when done + +#### Review + +Once you finish your changes, Github will send me a notification that a pull request has been submitted. I will take a look at it within a day or two and attempt to verify that the changes make sense by: + +- Confirming that the file name and the third line of the file match one of the supported locale names +- Viewing each change string in-game +- Checking Google Translate +- Asking individual human experts +- Requesting help on the KSP forum + +If I have any questions about specific changes you've made, I will add them to the pull request, which should trigger a notification to you. Please try to respond to these in as timely a manner as you can manage. Your pull request may be closed without merging if you do not reply for a long time. + +Once all the questions and comments are resolved to my satisfaction, your changes will be merged into the main files and included in the next release. I will also add your Github name to the Acknowledgements section of the README file. ## [Issues](https://github.com/HebaruSan/Astrogator/issues) diff --git a/Makefile b/Makefile index e3ba86e..2fc30db 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,14 @@ .PHONY: all clean SOURCEDIR=src -SOURCE=$(wildcard $(SOURCEDIR)/*.cs) +SOURCE=$(wildcard $(SOURCEDIR)/*.cs) $(wildcard $(SOURCEDIR)/*.csproj) ASSETDIR=assets ICONS=$(wildcard $(ASSETDIR)/*.png) CONFIGS=$(wildcard $(ASSETDIR)/*.cfg) +LANGUAGES=$(ASSETDIR)/lang README=README.md GAMELINK=$(SOURCEDIR)/KSP_x64_Data -DEFAULTGAMEDIR="$(HOME)/.local/share/Steam/SteamApps/common/Kerbal Space Program" +DEFAULTGAMEDIR=$(HOME)/.local/share/Steam/SteamApps/common/Kerbal Space Program DEBUGDLL=$(SOURCEDIR)/bin/Debug/Astrogator.dll RELEASEDLL=$(SOURCEDIR)/bin/Release/Astrogator.dll @@ -36,16 +37,16 @@ $(DEBUGDLL): $(SOURCE) $(GAMELINK) $(RELEASEDLL): $(SOURCE) $(GAMELINK) cd $(SOURCEDIR) && xbuild /p:Configuration=Release -$(RELEASEZIP): $(DEBUGDLL) $(ICONS) $(README) $(DLLDOCS) $(DLLSYMBOLS) $(LICENSE) $(VERSION) $(CONFIGS) +$(RELEASEZIP): $(RELEASEDLL) $(ICONS) $(README) $(DLLDOCS) $(DLLSYMBOLS) $(LICENSE) $(VERSION) $(CONFIGS) $(LANGUAGES) mkdir -p $(DISTDIR) - cp $^ $(DISTDIR) - zip -r $@ $(DISTDIR) + cp -a $^ $(DISTDIR) + zip -r $@ $(DISTDIR) -x \*.settings $(GAMELINK): if [ -x "$(DEFAULTGAMEDIR)" ]; \ - then; \ + then \ ln -s "$(DEFAULTGAMEDIR)"/KSP_x64_Data $(GAMELINK); \ - else; \ + else \ echo "$(GAMELINK) not found."; \ echo 'This must be a symlink to Kerbal Space Program/KSP_x64_Data.'; \ exit 2; \ diff --git a/README.md b/README.md index 5e8a833..ff17792 100644 --- a/README.md +++ b/README.md @@ -84,12 +84,15 @@ See [INSTALL.md](INSTALL.md). ## References ### Plug-in authoring +- https://kerbalspaceprogram.com/api/index.html - http://forum.kerbalspaceprogram.com/index.php?/topic/153765-getting-started-the-basics-of-writing-a-plug-in/ - http://forum.kerbalspaceprogram.com/index.php?/topic/151354-unity-ui-creation-tutorial/ - http://forum.kerbalspaceprogram.com/index.php?/topic/149324-popupdialog-and-the-dialoggui-classes/ - http://forum.kerbalspaceprogram.com/index.php?/topic/78231-application-launcher-and-mods/ - http://forum.kerbalspaceprogram.com/index.php?/topic/154006-solved-texture-issues/&do=findComment&comment=2904233 -- https://kerbalspaceprogram.com/api/index.html + +### Localization +- http://forum.kerbalspaceprogram.com/index.php?/topic/158018-addon-localization-home/ ### Physics and math - https://en.wikipedia.org/wiki/Hohmann_transfer_orbit @@ -99,6 +102,8 @@ See [INSTALL.md](INSTALL.md). - https://d2r5da613aq50s.cloudfront.net/wp-content/uploads/411616.image0.jpg - https://en.wikipedia.org/wiki/Orbital_inclination_change#Calculation - https://en.wikipedia.org/wiki/Hyperbolic_trajectory#Hyperbolic_excess_velocity +- http://www.dtic.mil/dtic/tr/fulltext/u2/a200383.pdf +- http://forum.kerbalspaceprogram.com/index.php?/topic/122779-changing-orbital-angle-without-changing-apoapsis/ ### Performance - http://www.somasim.com/blog/2015/04/csharp-memory-and-performance-tips-for-unity/ diff --git a/TODO.md b/TODO.md index 4b39577..08d70e6 100644 --- a/TODO.md +++ b/TODO.md @@ -10,7 +10,11 @@ - Only rule out a range once the entire thing is overdue - [ ] Merge the correction burn into the ejection burn - [ ] Re-do launch approximation to increase accuracy -- [ ] i18n / l10n (once SQUAD releases their version of it) + +## Localization clean-up + +- [ ] ["the Mun"](http://bugs.kerbalspaceprogram.com/issues/14314) +- [ ] Times not showing up in Chinese and Japanese ## Fixes diff --git a/assets/lang/en-us.cfg b/assets/lang/en-us.cfg new file mode 100644 index 0000000..9012107 --- /dev/null +++ b/assets/lang/en-us.cfg @@ -0,0 +1,50 @@ +Localization +{ + en-us + { + astrogator_mainTitle = Astrogator + astrogator_versionFormat = v<<1>>.<<2>>.<<3>> + astrogator_mainTooltip = Summary of transfer windows of reachable bodies + astrogator_normalSubtitle = Transfers from <<1>> + astrogator_inboundHyperbolicWarning = <<1>> is on an escape trajectory.\nCapture to see more transfers. + astrogator_outboundHyperbolicError = <<1>> is on an escape trajectory.\nCapture to see transfers. + astrogator_landedError = <<1>> is landed. Launch to orbit to see transfers. + astrogator_highInclinationError = Inclination is <<1>>°, accuracy too low past <<2>>° + astrogator_noTransfersError = No transfers available + astrogator_launchSubtitle = Transfers from <<1>>\n(Launch ~<<2>>) + astrogator_transferColumnHeader = Transfer + astrogator_timeColumnHeader = Time Till Burn + astrogator_deltaVColumnHeader = Δv + astrogator_planetLabel = <<1>> + astrogator_maneuverButtonTooltip = Create maneuver + astrogator_warpButtonTooltip = Warp to window + astrogator_yearsValue = <<1>>y + astrogator_daysValue = <<1>>d + astrogator_hoursValue = <<1>>h + astrogator_minutesValue = <<1>>m + astrogator_secondsValue = <<1>>s + astrogator_settingsButtonTooltip = Settings + astrogator_columnHeaderTooltip = Sort + astrogator_translationControlsNotification = Use translation controls to adjust nodes + astrogator_adjustManeuversMessage = Adjust maneuvers to establish encounter + astrogator_manualLink = Click for online manual + astrogator_manualLinkTooltip = The meaning of each setting is explained in the README.md file + astrogator_settingsSectionHeader = Settings: + astrogator_planeChangeBurnsSetting = Generate plane change burns + astrogator_addChangeBurnsSetting = Add plane change burns to Δv column + astrogator_autoDeleteNodesSetting = Auto-delete user-created maneuver nodes + astrogator_asteroidsSetting = Calculate transfers to tracked asteroids + astrogator_maneuverCreationHeader = Maneuver creation: + astrogator_autoTargetDestSetting = Automatically target destination + astrogator_autoFocusDestSetting = Automatically focus destination + astrogator_autoEditEjecSetting = Automatically edit ejection node + astrogator_autoEditPlaneChgSetting = Automatically edit plane change node + astrogator_autoSetSASSetting = Automatically set SAS to maneuver mode + astrogator_adjustNodesSetting = Adjust nodes with translation controls when RCS is off + astrogator_unitsHeader = Units: + astrogator_metricSetting = Système International d'Unités (Metric) + astrogator_imperialSetting = United States Customary (Imperial) + astrogator_speedMetric = <<1>> m/s + astrogator_speedUSCustomary = <<1>> mph + } +} diff --git a/assets/lang/es-es.cfg.google-translate b/assets/lang/es-es.cfg.google-translate new file mode 100644 index 0000000..1da96ab --- /dev/null +++ b/assets/lang/es-es.cfg.google-translate @@ -0,0 +1,50 @@ +Localization +{ + es-es + { + astrogator_mainTitle = Astrogador + astrogator_versionFormat = v<<1>>.<<2>>.<<3>> + astrogator_mainTooltip = Resumen de ventanas de transferencia de cuerpos accesibles + astrogator_normalSubtitle = Transferencias desde <> + astrogator_inboundHyperbolicWarning = <<1>> está en una trayectoria de escape.\nCaptura para ver más transferencias. + astrogator_outboundHyperbolicError = <<1>> está en una trayectoria de escape.\nCaptura para ver transferencias. + astrogator_landedError = <<1>> se desembarca. Iniciar en órbita para ver las transferencias. + astrogator_highInclinationError = La inclinación es <<1>>°, la precisión es demasiado baja después de <<2>>° + astrogator_noTransfersError = No hay transferencias disponibles + astrogator_launchSubtitle = Transferencias de <>\n(Lanzamiento ~<<2>>) + astrogator_transferColumnHeader = Transferir + astrogator_timeColumnHeader = Tiempo hasta quemar + astrogator_deltaVColumnHeader = Δv + astrogator_planetLabel = <<1>> + astrogator_maneuverButtonTooltip = Crear maniobra + astrogator_warpButtonTooltip = Deformar a la ventana + astrogator_yearsValue = <<1>>a + astrogator_daysValue = <<1>>d + astrogator_hoursValue = <<1>>h + astrogator_minutesValue = <<1>>m + astrogator_secondsValue = <<1>>s + astrogator_settingsButtonTooltip = Ajustes + astrogator_columnHeaderTooltip = Ordenar + astrogator_translationControlsNotification = Usar controles de traducción para ajustar nodos + astrogator_adjustManeuversMessage = Ajuste las maniobras para establecer el encuentro + astrogator_manualLink = Haga clic para obtener el manual en línea + astrogator_manualLinkTooltip = El significado de cada configuración se explica en el archivo README.md + astrogator_settingsSectionHeader = Ajustes: + astrogator_planeChangeBurnsSetting = Generar quemaduras de cambio de plano + astrogator_addChangeBurnsSetting = Añadir el plano cambie las quemaduras a la columna Δv + astrogator_autoDeleteNodesSetting = Eliminación automática de nodos de maniobra creados por el usuario + astrogator_asteroidsSetting = Calcular transferencias a asteroides rastreados + astrogator_maneuverCreationHeader = Creación de maniobras: + astrogator_autoTargetDestSetting = Destino de destino automático + astrogator_autoFocusDestSetting = Enfocar destino automáticamente + astrogator_autoEditEjecSetting = Editar automáticamente nodo de expulsión + astrogator_autoEditPlaneChgSetting = Editar automáticamente nodo de cambio de plano + astrogator_autoSetSASSetting = Establecer automáticamente SAS en modo de maniobra + astrogator_adjustNodesSetting = Ajustar nodos con controles de traducción cuando RCS está desactivado + astrogator_unitsHeader = Unidades: + astrogator_metricSetting = Système International d'Unités (Métrico) + astrogator_imperialSetting = United States Customary (Imperial) + astrogator_speedMetric = <<1>> m/s + astrogator_speedUSCustomary = <<1>> mph + } +} diff --git a/assets/lang/ja.cfg.google-translate b/assets/lang/ja.cfg.google-translate new file mode 100644 index 0000000..8206653 --- /dev/null +++ b/assets/lang/ja.cfg.google-translate @@ -0,0 +1,50 @@ +Localization +{ + ja + { + astrogator_mainTitle = アストロゲーター + astrogator_versionFormat = バ<<1>>。<<2>>。<<3>> + astrogator_mainTooltip = 到達可能なボディの転送ウィンドウの概要 + astrogator_normalSubtitle = <> からの転送 + astrogator_inboundHyperbolicWarning = <<1>> はエスケープ軌道上にあります。\n移動をもっと見るためにキャプチャしてください。 + astrogator_outboundHyperbolicError = <<1>> はエスケープ軌道上にあります。\n移動を見るためにキャプチャしてください。 + astrogator_landedError = <<1>> が上陸しました。軌道に乗って移動を見る。 + astrogator_highInclinationError = 傾斜が <<1>>°、精度が低すぎる <<2>>° + astrogator_noTransfersError = 利用可能な転送はありません + astrogator_launchSubtitle = <> からの転送\n起動 〜<<2>>) + astrogator_transferColumnHeader = 転送 + astrogator_timeColumnHeader = 書き込みまでの時間 + astrogator_deltaVColumnHeader = Δ速 + astrogator_planetLabel = <<1>> + astrogator_maneuverButtonTooltip = マヌーバを作成する + astrogator_warpButtonTooltip = ウィンドウにワープする + astrogator_yearsValue = <<1>>年 + astrogator_daysValue = <<1>>日 + astrogator_hoursValue = <<1>>時 + astrogator_minutesValue = <<1>>分 + astrogator_secondsValue = <<1>>秒 + astrogator_settingsButtonTooltip = 設定 + astrogator_columnHeaderTooltip = ソート + astrogator_translationControlsNotification = 翻訳コントロールを使用してノードを調整する + astrogator_adjustManeuversMessage = マヌーバを調整して遭遇を確立する + astrogator_manualLink = オンラインマニュアルを見る + astrogator_manualLinkTooltip = 各設定の意味は、README.mdファイルで説明しています + astrogator_settingsSectionHeader = 設定: + astrogator_planeChangeBurnsSetting = 平面変化バーンを生成する + astrogator_addChangeBurnsSetting = ΔV列に平面変化バーンを追加する + astrogator_autoDeleteNodesSetting = ユーザ作成の操作ノードを自動削除する + astrogator_asteroidsSetting = 追跡された小惑星への移動を計算する + astrogator_maneuverCreationHeader = マヌーバ作成: + astrogator_autoTargetDestSetting = 自動的にターゲットをターゲットに設定する + astrogator_autoFocusDestSetting = 自動的に焦点を合わせる + astrogator_autoEditEjecSetting = イジェクトノードを自動的に編集する + astrogator_autoEditPlaneChgSetting = 平面変更ノードを自動的に編集する + astrogator_autoSetSASSetting = SAS を手動モードに自動的に設定する + astrogator_adjustNodesSetting = RCS がオフのときに翻訳コントロールでノードを調整する + astrogator_unitsHeader = ユニット: + astrogator_metricSetting = Système International d'Unités(メートル法) + astrogator_imperialSetting = 米国慣習(インペリアル) + astrogator_speedMetric = <<1>> メートル/秒 + astrogator_speedUSCustomer = <<1>> 1時間あたりのマイル + } +} diff --git a/assets/lang/ru.cfg.google-translate b/assets/lang/ru.cfg.google-translate new file mode 100644 index 0000000..9543aec --- /dev/null +++ b/assets/lang/ru.cfg.google-translate @@ -0,0 +1,50 @@ +Localization +{ + ru + { + astrogator_mainTitle = Астрогатор + astrogator_versionFormat = в<<1>>.<<2>>.<<3>> + astrogator_mainTooltip = сводка о переносе окон достижимых тел + astrogator_normalSubtitle = Трансферы от <> + astrogator_inboundHyperbolicWarning = <<1>> находится на траектории эвакуации.\nЗахват, чтобы увидеть больше передач. + astrogator_outboundHyperbolicError = <<1>> находится на траектории эвакуации.\nЗахват для просмотра передач. + astrogator_landedError = <<1>> выгружается. Запуск на орбиту, чтобы увидеть передачи. + astrogator_highInclinationError = Наклонение равно <<1>>°, точность слишком низкая мимо <<2>>° + astrogator_noTransfersError = Нет доступных передач + astrogator_launchSubtitle = передачи из <>\n(запуск ~<<2>>) + astrogator_transferColumnHeader = Перенос + astrogator_timeColumnHeader = Время до сжигания + astrogator_deltaVColumnHeader = Δс + astrogator_planetLabel = <<1>> + astrogator_maneuverButtonTooltip = Создать маневр + astrogator_warpButtonTooltip = Перейти к окну + astrogator_yearsValue = <<1>>Л + astrogator_daysValue = <<1>>Д + astrogator_hoursValue = <<1>>Ч + astrogator_minutesValue = <<1>>М + astrogator_secondsValue = <<1>>С + astrogator_settingsButtonTooltip = Настройки + astrogator_columnHeaderTooltip = Сортировать + astrogator_translationControlsNotification = использовать элементы управления трансляцией для настройки узлов + astrogator_adjustManeuversMessage = Настроить маневры для установления встречи + astrogator_manualLink = Нажмите для онлайн-руководства + astrogator_manualLinkTooltip = Значение каждого параметра объясняется в файле README.md + astrogator_settingsSectionHeader = Настройки: + astrogator_planeChangeBurnsSetting = Генерация изменений смены плоскости + astrogator_addChangeBurnsSetting = Добавить изменения смены плоскости на Δv столбец + astrogator_autoDeleteNodesSetting = Автоматическое удаление созданных пользователем узлов маневра + astrogator_asteroidsSetting = Рассчитать переводы на отслеживаемые астероиды + astrogator_maneuverCreationHeader = Создание маневра: + astrogator_autoTargetDestSetting = автоматически целевое назначение + astrogator_autoFocusDestSetting = Автоматическое назначение фокуса + astrogator_autoEditEjecSetting = Автоматически редактировать узел выталкивания + astrogator_autoEditPlaneChgSetting = Автоматическое редактирование узла изменения плоскости + astrogator_autoSetSASSetting = автоматически настроить режим SAS для маневра + astrogator_adjustNodesSetting = Настроить узлы с помощью средств управления переводом, когда RCS выключен + astrogator_unitsHeader = Единицы измерения: + astrogator_metricSetting = Système International d'Unités (метрическая система) + astrogator_imperialSetting = Соединенные Штаты Америки (императорский) + astrogator_speedMetric = <<1>> М/C + astrogator_speedUSCustomary = <<1>> мвч + } +} diff --git a/assets/lang/zh-cn.cfg.google-translate b/assets/lang/zh-cn.cfg.google-translate new file mode 100644 index 0000000..b9e0a3e --- /dev/null +++ b/assets/lang/zh-cn.cfg.google-translate @@ -0,0 +1,50 @@ +Localization +{ + zh-cn + { + astrogator_mainTitle = 空间 航海家 + astrogator_versionFormat = 版<<1>>。<<2>>。<<3>> + astrogator_mainTooltip = 可达物体的转移窗口总结 + astrogator_normalSubtitle = 从<>传输 + astrogator_inboundHyperbolicWarning = <<1>>正在逃生轨迹上。\n捕获以查看更多转移。 + astrogator_outboundHyperbolicError = <<1>>处于逃生轨迹。\n捕获以查看传输。 + astrogator_landedError = <<1>>登陆。发射到轨道看转移。 + astrogator_highInclinationError = 倾角为<<1>>°,精度过低<<2>>° + astrogator_noTransfersError = 没有可用的传输 + astrogator_launchSubtitle = 从<>\n(启动〜<<2>>) + astrogator_transferColumnHeader = 转移 + astrogator_timeColumnHeader = 烧伤时间 + astrogator_deltaVColumnHeader = Δ速 + astrogator_planetLabel = <<1>> + astrogator_maneuverButtonTooltip = 创建机动 + astrogator_warpButtonTooltip = 扭曲到窗口 + astrogator_yearsValue = <<1>>年 + astrogator_daysValue = <<1>>天 + astrogator_hoursValue = <<1>>小 + astrogator_minutesValue = <<1>>分 + astrogator_secondsValue = <<1>>秒 + astrogator_settingsButtonTooltip = 设置 + astrogator_columnHeaderTooltip = 排序 + astrogator_translationControlsNotification = 使用翻译控件来调整节点 + astrogator_adjustManeuversMessage = 调整机动来建立相遇 + astrogator_manualLink = 点击在线手册 + astrogator_manualLinkTooltip = 每个设置的含义在README.md文件中解释 + astrogator_settingsSectionHeader = 设置: + astrogator_planeChangeBurnsSetting = 生成平面变化刻录 + astrogator_addChangeBurnsSetting = 将平面更改刻录到Δv列 + astrogator_autoDeleteNodesSetting = 自动删除用户创建的机动节点 + astrogator_asteroidsSetting = 计算到跟踪小行星的转移 + astrogator_maneuverCreationHeader = 机动创作: + astrogator_autoTargetDestSetting = 自动定位目的地 + astrogator_autoFocusDestSetting = 自动对焦目的地 + astrogator_autoEditEjecSetting = 自动编辑弹出节点 + astrogator_autoEditPlaneChgSetting = 自动编辑平面变化节点 + astrogator_autoSetSASSetting = 自动将SAS设置为机动模式 + astrogator_adjustNodesSetting = 当RCS关闭时调整带有翻译控件的节点 + astrogator_unitsHeader = 单位: + astrogator_metricSetting = 国际单位(公制) + astrogator_imperialSetting = 美国习惯(帝国) + astrogator_speedMetric = <<1>> 米/秒 + astrogator_speedUSCustomary = <<1>> 英里每小时 + } +} diff --git "a/screenshots/espa\303\261ol.png" "b/screenshots/espa\303\261ol.png" new file mode 100644 index 0000000..546f38a Binary files /dev/null and "b/screenshots/espa\303\261ol.png" differ diff --git a/screenshots/google-translations.png b/screenshots/google-translations.png new file mode 100644 index 0000000..aabb420 Binary files /dev/null and b/screenshots/google-translations.png differ diff --git a/screenshots/settings-en-espanol.png b/screenshots/settings-en-espanol.png new file mode 100644 index 0000000..19e4c8b Binary files /dev/null and b/screenshots/settings-en-espanol.png differ diff --git a/screenshots/sort-caret-and-The-Mun.png b/screenshots/sort-caret-and-The-Mun.png new file mode 100644 index 0000000..213d290 Binary files /dev/null and b/screenshots/sort-caret-and-The-Mun.png differ diff --git a/src/AstrogationModel.cs b/src/AstrogationModel.cs index 97ef8f6..e78bb6b 100644 --- a/src/AstrogationModel.cs +++ b/src/AstrogationModel.cs @@ -17,7 +17,7 @@ public class AstrogationModel { /// Body or vessel to start at public AstrogationModel(ITargetable org) { - origin = org; + origin = org; transfers = new List(); if (!ErrorCondition) { @@ -160,12 +160,12 @@ private void CreateTransfers(ITargetable start) b != null; toSkip = b, b = ParentBody(b)) { - DbgFmt("Checking transfers around {0}", b.theName); + DbgFmt("Checking transfers around {0}", TheName(b)); // It's worth calculating return-from-satellite burns for Eve, Kerbin, and Duna, // but not for Jool or the Sun. if (b.hasSolidSurface && b != first) { - DbgFmt("Adding return-to-parent transfer to {0}", b.theName); + DbgFmt("Adding return-to-parent transfer to {0}", TheName(b)); transfers.Add(new TransferModel(origin, b)); } @@ -173,7 +173,7 @@ private void CreateTransfers(ITargetable start) for (int i = 0; i < numBodies; ++i) { CelestialBody satellite = b.orbitingBodies[i]; if (satellite != toSkip) { - DbgFmt("Allocating transfer to {0}", satellite.theName); + DbgFmt("Allocating transfer to {0}", TheName(satellite)); transfers.Add(new TransferModel(origin, satellite)); if (satellite == targetBody) { diff --git a/src/AstrogationView.cs b/src/AstrogationView.cs index e974b3a..1b0cabe 100644 --- a/src/AstrogationView.cs +++ b/src/AstrogationView.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using UnityEngine; using UnityEngine.Events; +using KSP.Localization; namespace Astrogator { @@ -31,7 +32,7 @@ public AstrogationView(AstrogationModel m, ResetCallback reset, UnityAction clos TextAnchor.UpperCenter ) { - model = m; + model = m; resetCallback = reset; closeCallback = close; @@ -78,12 +79,6 @@ private void toggleSettingsVisible() resetCallback(); } - /// - /// The user-facing name for this mod. - /// Use Astrogator.Name for filenames, internal representations, CKAN, etc. - /// - public const string DisplayName = "Astrogator"; - /// /// UI object representing the top row of the table /// @@ -92,8 +87,8 @@ private void toggleSettingsVisible() private string columnSortIndicator(ColumnDefinition col) { return col.sortKey != Settings.Instance.TransferSort ? "" - : Settings.Instance.DescendingSort ? " ↓" - : " ↑"; + : Settings.Instance.DescendingSort ? " v" + : " ^"; } private void createHeaders() @@ -119,7 +114,7 @@ private void createHeaders() if (col.header != "") { ColumnHeaders.AddChild(headerButton( col.header + columnSortIndicator(col), - col.headerStyle, "Sort", width, rowHeight, () => { + col.headerStyle, Localizer.Format("astrogator_columnHeaderTooltip"), width, rowHeight, () => { SortClicked(col.sortKey); } )); @@ -199,36 +194,36 @@ private string subTitle { return "Model's origin is null"; } else if (model.hyperbolicOrbit) { if (model.inbound) { - return string.Format( - "{0} is on an escape trajectory.\nCapture to see more transfers.", + return Localizer.Format( + "astrogator_inboundHyperbolicWarning", TheName(model.origin) ); } else { - return string.Format( - "{0} is on an escape trajectory.\nCapture to see transfers.", + return Localizer.Format( + "astrogator_outboundHyperbolicError", TheName(model.origin) ); } } else if (model.badInclination) { - return string.Format( - "Inclination is {0:0.0}°, accuracy too low past {1:0.}°", - AngleFromEquatorial(model.origin.GetOrbit().inclination * Mathf.Deg2Rad) * Mathf.Rad2Deg, - AstrogationModel.maxInclination * Mathf.Rad2Deg + return Localizer.Format( + "astrogator_highInclinationError", + (AngleFromEquatorial(model.origin.GetOrbit().inclination * Mathf.Deg2Rad) * Mathf.Rad2Deg).ToString("0.0"), + (AstrogationModel.maxInclination * Mathf.Rad2Deg).ToString("0") ); } else if (model.transfers.Count == 0) { - return "No transfers available"; + return Localizer.Format("astrogator_noTransfersError"); } else if (Landed(model.origin) || solidBodyWithoutVessel(model.origin)) { CelestialBody b = model.origin as CelestialBody; if (b == null) { b = model.origin.GetOrbit().referenceBody; } - return string.Format( - "Transfers from {0}\n(Launch ~{1})", + return Localizer.Format( + "astrogator_launchSubtitle", TheName(model.origin), FormatSpeed(DeltaVToOrbit(b), Settings.Instance.DisplayUnits) ); } else { - return string.Format("Transfers from {0}", TheName(model.origin)); + return Localizer.Format("astrogator_normalSubtitle", TheName(model.origin)); } } else { return "Internal error: Model not found"; @@ -242,7 +237,7 @@ private string getMessage() && Settings.Instance.TranslationAdjust && FlightGlobals.ActiveVessel != null && !FlightGlobals.ActiveVessel.ActionGroups[KSPActionGroup.RCS]) { - return "Use translation controls to adjust nodes"; + return Localizer.Format("astrogator_translationControlsNotification"); } else { return ""; } @@ -279,8 +274,9 @@ public PopupDialog Show() mainWindowAnchorMin, mainWindowAnchorMax, new MultiOptionDialog( + Localizer.Format("astrogator_mainTitle"), subTitle, - DisplayName + " " + versionString, + Localizer.Format("astrogator_mainTitle") + " " + versionString, skinToUse, geometry, this diff --git a/src/Astrogator.cs b/src/Astrogator.cs index b39fe82..c8c8521 100644 --- a/src/Astrogator.cs +++ b/src/Astrogator.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using KSP.UI.Screens; +using KSP.Localization; namespace Astrogator { @@ -44,11 +45,6 @@ public Astrogator() /// public const string Name = "Astrogator"; - /// - /// Text to be shown in the tooltip to explain what this mod does. - /// - public const string Description = "Summary of transfer windows of reachable bodies"; - /// /// This is called at creation /// @@ -164,8 +160,8 @@ private void onAppLaunchHover() if (tooltip == null) { tooltip = TooltipView.AppLauncherTooltip( - AstrogationView.DisplayName, - Description, + Localizer.Format("astrogator_mainTitle"), + Localizer.Format("astrogator_mainTooltip"), launcher); } tooltip.Show(); @@ -490,7 +486,7 @@ private void OnSituationChanged(GameEvents.HostedFromToAction - + Debug @@ -12,6 +12,8 @@ v3.5 512 + 8.0.30703 + 2.0 true @@ -36,25 +38,21 @@ - - False + + KSP_x64_Data\Managed\KSPAssets.dll + + KSP_x64_Data\Managed\Assembly-CSharp.dll - - False + KSP_x64_Data\Managed\UnityEngine.dll - - False + KSP_x64_Data\Managed\Assembly-CSharp-firstpass.dll - - False + KSP_x64_Data\Managed\UnityEngine.UI.dll - - KSP_x64_Data\Managed\KSPAssets.dll - diff --git a/src/AstrogatorMenu.cs b/src/AstrogatorMenu.cs index 340aaa0..491b7b8 100644 --- a/src/AstrogatorMenu.cs +++ b/src/AstrogatorMenu.cs @@ -3,6 +3,7 @@ using System.Globalization; using System.Collections.Generic; using UnityEngine; +using KSP.Localization; namespace Astrogator { @@ -155,7 +156,7 @@ private string colContentFormat(ColumnDefinition col) private void addRow(StringBuilder sb, TransferModel m, DateTimeParts dt, bool selected) { - string destLabel = CultureInfo.InstalledUICulture.TextInfo.ToTitleCase(TheName(m.destination)); + string destLabel = Localizer.Format("astrogatr_planetLabel", TheName(m.destination)); sb.Append(Environment.NewLine); sb.Append(selected ? "> " : " "); @@ -176,7 +177,7 @@ private void addRow(StringBuilder sb, TransferModel m, DateTimeParts dt, bool se } else { sb.AppendFormat( colContentFormat(col), - TimePieceString("{0}y", dt.years, dt.needYears) + TimePieceString("astrogator_yearsValue", dt.years, dt.needYears) ); } break; @@ -187,7 +188,7 @@ private void addRow(StringBuilder sb, TransferModel m, DateTimeParts dt, bool se } else { sb.AppendFormat( colContentFormat(col), - TimePieceString("{0}d", dt.days, dt.needDays) + TimePieceString("astrogator_daysValue", dt.days, dt.needDays) ); } break; @@ -198,7 +199,7 @@ private void addRow(StringBuilder sb, TransferModel m, DateTimeParts dt, bool se } else { sb.AppendFormat( colContentFormat(col), - TimePieceString("{0}h", dt.hours, dt.needHours) + TimePieceString("astrogator_hoursValue", dt.hours, dt.needHours) ); } break; @@ -209,7 +210,7 @@ private void addRow(StringBuilder sb, TransferModel m, DateTimeParts dt, bool se } else { sb.AppendFormat( colContentFormat(col), - TimePieceString("{0}m", dt.minutes, dt.needMinutes) + TimePieceString("astrogator_minutesValue", dt.minutes, dt.needMinutes) ); } break; @@ -220,7 +221,7 @@ private void addRow(StringBuilder sb, TransferModel m, DateTimeParts dt, bool se } else { sb.AppendFormat( colContentFormat(col), - TimePieceString("{0}s", dt.seconds, true) + TimePieceString("astrogator_secondsValue", dt.seconds, true) ); } break; @@ -264,10 +265,10 @@ public string ShowMenu(int columns, int rows) if ((Refresh() || cursorMoved) && transfers.Count == timeToWait.Count) { StringBuilder sb = new StringBuilder(); - sb.Append(centerString(" " + AstrogationView.DisplayName + " " + versionString + " ", columns, '-')); + sb.Append(centerString(" " + Localizer.Format("astrogator_mainTitle") + " " + versionString + " ", columns, '-')); sb.Append(Environment.NewLine); sb.Append("[#a0a0a0ff]"); - sb.Append(centerString(String.Format("Transfers from {0}", TheName(model.origin)), columns)); + sb.Append(centerString(Localizer.Format("astrogator_normalSubtitle", TheName(model.origin)), columns)); sb.Append(Environment.NewLine); sb.Append(Environment.NewLine); diff --git a/src/BurnModel.cs b/src/BurnModel.cs index 981c140..c874643 100644 --- a/src/BurnModel.cs +++ b/src/BurnModel.cs @@ -18,10 +18,10 @@ public class BurnModel { /// Radial component public BurnModel(double? t, double pro, double nor = 0, double rad = 0) { - atTime = t; - prograde = pro; - normal = nor; - radial = rad; + atTime = t; + prograde = pro; + normal = nor; + radial = rad; totalDeltaV = Math.Sqrt(prograde * prograde + normal * normal + radial * radial); } diff --git a/src/DebugTools.cs b/src/DebugTools.cs index 7a0fcdc..fa89e66 100644 --- a/src/DebugTools.cs +++ b/src/DebugTools.cs @@ -1,6 +1,7 @@ using System; using UnityEngine; using KSP; +using KSP.Localization; namespace Astrogator { @@ -24,7 +25,7 @@ public static void DbgFmt(string format, params object[] args) lock (debugMutex) { Debug.Log(string.Format( "[{0} {1:000.000}] {2}", - AstrogationView.DisplayName, + Localizer.Format("astrogator_mainTitle"), Time.realtimeSinceStartup, formattedMessage )); diff --git a/src/KerbalTools.cs b/src/KerbalTools.cs index 0e0899e..4712796 100644 --- a/src/KerbalTools.cs +++ b/src/KerbalTools.cs @@ -195,12 +195,16 @@ public static double SphereOfInfluence(ITargetable target) /// /// Body or vessel to check /// - /// Name of target, possibly with "the" in front + /// Name of target, including gender markers + /// (Historically, this checked CelestialBody.theName, which included a lower case + /// version of some names such as "the Mun". This was removed in the localization + /// update, and now we only have "The Mun" regardless of where in the sentence + /// the string will be used. This has been reported on the bug tracker: + /// http://bugs.kerbalspaceprogram.com/issues/14314 ) /// public static string TheName(ITargetable target) { - CelestialBody b = target as CelestialBody; - return b?.theName ?? target?.GetName() ?? "NULL"; + return target?.GetDisplayName() ?? target?.GetName() ?? "NULL"; } /// @@ -274,5 +278,21 @@ public static void ClearManeuverNodes() } } + /// + /// The full relative path from the main KSP folder to a given resource from this mod. + /// + /// Name of file located in our plugin folder + /// True if the KSP/GameData portion of the path is assumed, false if we need to provide the full path + public static string FilePath(string filename, bool GameDataRelative = true) + { + if (GameDataRelative) { + return string.Format("{0}/{1}", Astrogator.Name, filename); + } else { + return string.Format("{0}/{1}", + System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), + filename); + } + } + } } diff --git a/src/OrbitModel.cs b/src/OrbitModel.cs index 27906fa..9a8e765 100644 --- a/src/OrbitModel.cs +++ b/src/OrbitModel.cs @@ -14,11 +14,11 @@ public class OrbitModel { /// Orbit from which to copy orbital parameters public OrbitModel(Orbit o) { - SemiMajorAxis = o.semiMajorAxis; - Eccentricity = o.eccentricity; - Inclination = o.inclination; + SemiMajorAxis = o.semiMajorAxis; + Eccentricity = o.eccentricity; + Inclination = o.inclination; LongitudeOfAscendingNode = o.LAN; - ArgumentOfPeriapsis = o.argumentOfPeriapsis; + ArgumentOfPeriapsis = o.argumentOfPeriapsis; } private double SemiMajorAxis { get; set; } diff --git a/src/Properties/AssemblyInfo.cs b/src/Properties/AssemblyInfo.cs index 3a60d49..e210b8b 100644 --- a/src/Properties/AssemblyInfo.cs +++ b/src/Properties/AssemblyInfo.cs @@ -31,5 +31,5 @@ // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("0.6.2.0")] -[assembly: AssemblyFileVersion("0.6.2.0")] +[assembly: AssemblyVersion("0.7.0.0")] +[assembly: AssemblyFileVersion("0.7.0.0")] diff --git a/src/Settings.cs b/src/Settings.cs index 0c15f6e..9bb78d6 100644 --- a/src/Settings.cs +++ b/src/Settings.cs @@ -4,6 +4,7 @@ namespace Astrogator { using static DebugTools; + using static KerbalTools; using static ViewTools; /// diff --git a/src/SettingsView.cs b/src/SettingsView.cs index 2b919be..5f912b2 100644 --- a/src/SettingsView.cs +++ b/src/SettingsView.cs @@ -1,5 +1,6 @@ using System; using UnityEngine; +using KSP.Localization; namespace Astrogator { @@ -28,26 +29,26 @@ public SettingsView(AstrogationView.ResetCallback reset) try { AddChild(headerButton( - "Click for online manual", - linkStyle, "The meaning of each setting is explained in the README.md file", RowWidth, rowHeight, + Localizer.Format("astrogator_manualLink"), + linkStyle, Localizer.Format("astrogator_manualLinkTooltip"), RowWidth, rowHeight, () => { Application.OpenURL(docsURL); } )); AddChild(LabelWithStyleAndSize( - "Settings:", + Localizer.Format("astrogator_settingsSectionHeader"), midHdrStyle, mainWindowMinWidth, rowHeight )); AddChild(new DialogGUIToggle( () => Settings.Instance.GeneratePlaneChangeBurns, - "Generate plane change burns", + Localizer.Format("astrogator_planeChangeBurnsSetting"), (bool b) => { Settings.Instance.GeneratePlaneChangeBurns = b; } )); AddChild(new DialogGUIToggle( () => Settings.Instance.AddPlaneChangeDeltaV, - "Add plane change burns to Δv column", + Localizer.Format("astrogator_addChangeBurnsSetting"), (bool b) => { Settings.Instance.AddPlaneChangeDeltaV = b; // Only need to reload if we don't already have the plane change values @@ -59,73 +60,73 @@ public SettingsView(AstrogationView.ResetCallback reset) AddChild(new DialogGUIToggle( () => Settings.Instance.DeleteExistingManeuvers, - "Auto-delete user-created maneuver nodes", + Localizer.Format("astrogator_autoDeleteNodesSetting"), (bool b) => { Settings.Instance.DeleteExistingManeuvers = b; } )); AddChild(new DialogGUIToggle( () => Settings.Instance.ShowTrackedAsteroids, - "Calculate transfers to tracked asteroids", + Localizer.Format("astrogator_asteroidsSetting"), (bool b) => { Settings.Instance.ShowTrackedAsteroids = b; resetCallback(true); } )); AddChild(LabelWithStyleAndSize( - "Maneuver creation:", + Localizer.Format("astrogator_maneuverCreationHeader"), midHdrStyle, mainWindowMinWidth, rowHeight )); AddChild(new DialogGUIToggle( () => Settings.Instance.AutoTargetDestination, - "Automatically target destination", + Localizer.Format("astrogator_autoTargetDestSetting"), (bool b) => { Settings.Instance.AutoTargetDestination = b; } )); AddChild(new DialogGUIToggle( () => Settings.Instance.AutoFocusDestination, - "Automatically focus destination", + Localizer.Format("astrogator_autoFocusDestSetting"), (bool b) => { Settings.Instance.AutoFocusDestination = b; } )); AddChild(new DialogGUIToggle( () => Settings.Instance.AutoEditEjectionNode, - "Automatically edit ejection node", + Localizer.Format("astrogator_autoEditEjecSetting"), (bool b) => { Settings.Instance.AutoEditEjectionNode = b; } )); AddChild(new DialogGUIToggle( () => Settings.Instance.AutoEditPlaneChangeNode, - "Automatically edit plane change node", + Localizer.Format("astrogator_autoEditPlaneChgSetting"), (bool b) => { Settings.Instance.AutoEditPlaneChangeNode = b; } )); AddChild(new DialogGUIToggle( () => Settings.Instance.AutoSetSAS, - "Automatically set SAS to maneuver mode", + Localizer.Format("astrogator_autoSetSASSetting"), (bool b) => { Settings.Instance.AutoSetSAS = b; } )); AddChild(new DialogGUIToggle( () => Settings.Instance.TranslationAdjust, - "Adjust nodes with translation controls when RCS is off", + Localizer.Format("astrogator_adjustNodesSetting"), (bool b) => { Settings.Instance.TranslationAdjust = b; } )); AddChild(LabelWithStyleAndSize( - "Units:", + Localizer.Format("astrogator_unitsHeader"), midHdrStyle, mainWindowMinWidth, rowHeight )); AddChild(new DialogGUIToggle( () => Settings.Instance.DisplayUnits == DisplayUnitsEnum.Metric, - "Système International d'Unités (Metric)", + Localizer.Format("astrogator_metricSetting"), (bool b) => { if (b) Settings.Instance.DisplayUnits = DisplayUnitsEnum.Metric; resetCallback(false); } )); AddChild(new DialogGUIToggle( () => Settings.Instance.DisplayUnits == DisplayUnitsEnum.UnitedStatesCustomary, - "United States Customary (Imperial)", + Localizer.Format("astrogator_imperialSetting"), (bool b) => { if (b) Settings.Instance.DisplayUnits = DisplayUnitsEnum.UnitedStatesCustomary; resetCallback(false); } )); diff --git a/src/TooltipView.cs b/src/TooltipView.cs index 42e94d4..0d00667 100644 --- a/src/TooltipView.cs +++ b/src/TooltipView.cs @@ -11,6 +11,7 @@ class TooltipView : MultiOptionDialog { public TooltipView(string title, string description, Rect where) : base( + " " + title + " ", description, " " + title + " ", AstrogatorSkin, diff --git a/src/TransferModel.cs b/src/TransferModel.cs index 5a7a6b6..43ea495 100644 --- a/src/TransferModel.cs +++ b/src/TransferModel.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using UnityEngine; using KSP; +using KSP.Localization; namespace Astrogator { @@ -744,7 +745,7 @@ public void CreateManeuvers() } else if (transferParent != null) { // Otherwise focus on the parent of the transfer orbit so we can get an encounter // Try to explain why this is happening with a screen message - ScreenFmt("Adjust maneuvers to establish encounter"); + ScreenFmt(Localizer.Format("astrogator_adjustManeuversMessage")); FocusMap(transferParent, transferDestination); } } diff --git a/src/TransferView.cs b/src/TransferView.cs index 17c7115..61a7240 100644 --- a/src/TransferView.cs +++ b/src/TransferView.cs @@ -1,5 +1,6 @@ using System; using System.Globalization; +using KSP.Localization; namespace Astrogator { @@ -57,7 +58,8 @@ private void CreateLayout() switch (col.content) { case ContentEnum.PlanetName: - AddChild(LabelWithStyleAndSize(CultureInfo.InstalledUICulture.TextInfo.ToTitleCase(TheName(model.destination)), + AddChild(LabelWithStyleAndSize( + Localizer.Format("astrogator_planetLabel", TheName(model.destination)), col.contentStyle, col.width, rowHeight)); break; @@ -93,12 +95,12 @@ private void CreateLayout() case ContentEnum.CreateManeuverNodeButton: AddChild(iconButton(maneuverIcon, - col.contentStyle, "Create maneuver", model.CreateManeuvers)); + col.contentStyle, Localizer.Format("astrogator_maneuverButtonTooltip"), model.CreateManeuvers)); break; case ContentEnum.WarpToBurnButton: AddChild(iconButton(warpIcon, - col.contentStyle, "Warp to window", model.WarpToBurn)); + col.contentStyle, Localizer.Format("astrogator_warpButtonTooltip"), model.WarpToBurn)); break; } @@ -146,7 +148,7 @@ public string getYearValue() if (showLoadingText) { return LoadingText; } else { - return TimePieceString("{0}y", timeToWait.years, timeToWait.needYears); + return TimePieceString("astrogator_yearsValue", timeToWait.years, timeToWait.needYears); } } @@ -159,7 +161,7 @@ public string getDayValue() if (showLoadingText) { return LoadingText; } else { - return TimePieceString("{0}d", timeToWait.days, timeToWait.needDays); + return TimePieceString("astrogator_daysValue", timeToWait.days, timeToWait.needDays); } } @@ -172,7 +174,7 @@ public string getHourValue() if (showLoadingText) { return LoadingText; } else { - return TimePieceString("{0}h", timeToWait.hours, timeToWait.needHours); + return TimePieceString("astrogator_hoursValue", timeToWait.hours, timeToWait.needHours); } } @@ -185,7 +187,7 @@ public string getMinuteValue() if (showLoadingText) { return LoadingText; } else { - return TimePieceString("{0}m", timeToWait.minutes, timeToWait.needMinutes); + return TimePieceString("astrogator_minutesValue", timeToWait.minutes, timeToWait.needMinutes); } } @@ -198,7 +200,7 @@ public string getSecondValue() if (showLoadingText) { return LoadingText; } else { - return TimePieceString("{0}s", timeToWait.seconds, true); + return TimePieceString("astrogator_secondsValue", timeToWait.seconds, true); } } diff --git a/src/ViewTools.cs b/src/ViewTools.cs index 93139bb..d3d455b 100644 --- a/src/ViewTools.cs +++ b/src/ViewTools.cs @@ -7,10 +7,12 @@ using UnityEngine.Events; using TMPro; using KSP.UI.TooltipTypes; +using KSP.Localization; namespace Astrogator { using static DebugTools; + using static KerbalTools; using static ViewTools; /// Anything UI-related that needs to be used from multiple places. @@ -36,17 +38,19 @@ public static class ViewTools { /// /// A string representing the version number of the mod. /// - public static string versionString = string.Format( - "v{0}.{1}.{2}", modVersion.Major, modVersion.Minor, modVersion.Build + public static string versionString = Localizer.Format( + "astrogator_versionFormat", modVersion.Major, modVersion.Minor, modVersion.Build ); /// - /// Sort the transfers from a model. + /// Return a list of a model's transfers sorted according to settings /// - /// List of sorted transfers - /// Model from which to sort transfers - /// Sort method + /// Model from which to get transfers + /// Method for sorting /// True for descending sort, false for ascending + /// + /// Sorted list + /// public static List SortTransfers(AstrogationModel m, SortEnum how, bool descend) { List transfers = new List(m.transfers); @@ -76,22 +80,6 @@ public static List SortTransfers(AstrogationModel m, SortEnum how return transfers; } - /// - /// The full relative path from the main KSP folder to a given resource from this mod. - /// - /// Name of file located in our plugin folder - /// True if the KSP/GameData portion of the path is assumed, false if we need to provide the full path - public static string FilePath(string filename, bool GameDataRelative = true) - { - if (GameDataRelative) { - return string.Format("{0}/{1}", Astrogator.Name, filename); - } else { - return string.Format("{0}/{1}", - System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), - filename); - } - } - /// /// Parse a string into an enum for Settings /// Inverse of Enum.ToString() @@ -714,7 +702,7 @@ public class ColumnDefinition { /// public static ColumnDefinition[] Columns = new ColumnDefinition[] { new ColumnDefinition() { - header = "Transfer", + header = Localizer.Format("astrogator_transferColumnHeader"), width = 60, headerColSpan = 1, headerStyle = leftHdrStyle, @@ -723,7 +711,7 @@ public class ColumnDefinition { sortKey = SortEnum.Position, monospaceWidth = 6 }, new ColumnDefinition() { - header = "Time Till Burn", + header = Localizer.Format("astrogator_timeColumnHeader"), width = 30, headerColSpan = 5, headerStyle = midHdrStyle, @@ -764,7 +752,7 @@ public class ColumnDefinition { content = ContentEnum.SecondsTillBurn, monospaceWidth = 3, }, new ColumnDefinition() { - header = "Δv", + header = Localizer.Format("astrogator_deltaVColumnHeader"), width = 60, headerColSpan = 1, headerStyle = rightHdrStyle, @@ -906,7 +894,7 @@ public static string TimePieceString(string fmt, double val, bool forceShow = fa if (!forceShow && val == 0) { return nullString; } else { - return string.Format(fmt, val); + return Localizer.Format(fmt, val); } } @@ -1037,10 +1025,10 @@ public static string FormatSpeed(double speed, DisplayUnitsEnum units) { const double METERS_PER_SECOND_PER_MILES_PER_HOUR = 0.44704; switch (units) { case DisplayUnitsEnum.UnitedStatesCustomary: - return string.Format("{0:0} mph", speed / METERS_PER_SECOND_PER_MILES_PER_HOUR); + return Localizer.Format("astrogator_speedUSCustomary", (speed / METERS_PER_SECOND_PER_MILES_PER_HOUR).ToString("0")); default: case DisplayUnitsEnum.Metric: - return string.Format("{0:0} m/s", speed); + return Localizer.Format("astrogator_speedMetric", speed.ToString("0")); } } }