mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-27 06:30:20 +00:00
feat: add more options to translation
This commit is contained in:
parent
04535749e9
commit
3269b2b5aa
4 changed files with 68 additions and 35 deletions
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "dioxusstudio",
|
||||
"displayName": "dioxusStudio",
|
||||
"description": "Toolkit for IDE support in Dioxus apps",
|
||||
"displayName": "Dioxus",
|
||||
"description": "Useful tools for working with Dioxus",
|
||||
"version": "0.0.1",
|
||||
"publisher": "jkelleyrtp",
|
||||
"private": true,
|
||||
|
|
|
@ -2,6 +2,7 @@ import * as vscode from 'vscode';
|
|||
import { spawn } from "child_process";
|
||||
|
||||
export function activate(context: vscode.ExtensionContext) {
|
||||
|
||||
function registerCommand(cmd: string) {
|
||||
function convert(cmd: string) {
|
||||
const editor = vscode.window.activeTextEditor;// Get the active text editor
|
||||
|
@ -10,7 +11,7 @@ export function activate(context: vscode.ExtensionContext) {
|
|||
if (html.length > 0) {
|
||||
let params = ["translate"];
|
||||
if (cmd.includes("Component")) params.push("--component");
|
||||
params.push("--source");
|
||||
params.push("--raw");
|
||||
params.push(html);
|
||||
const child_proc = spawn("dioxus", params);
|
||||
let result = '';
|
||||
|
@ -23,6 +24,8 @@ export function activate(context: vscode.ExtensionContext) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const handle = vscode.commands.registerCommand(cmd, () => convert(cmd));
|
||||
context.subscriptions.push(handle);
|
||||
}
|
||||
|
|
|
@ -13,6 +13,10 @@ pub struct Translate {
|
|||
#[clap(short, long)]
|
||||
pub file: Option<String>,
|
||||
|
||||
/// Input file
|
||||
#[clap(short, long)]
|
||||
pub raw: Option<String>,
|
||||
|
||||
/// Output file, stdout if not present
|
||||
#[clap(parse(from_os_str))]
|
||||
pub output: Option<PathBuf>,
|
||||
|
@ -24,14 +28,20 @@ impl Translate {
|
|||
component,
|
||||
output,
|
||||
file,
|
||||
raw,
|
||||
} = self;
|
||||
|
||||
let contents = match file {
|
||||
Some(input) => std::fs::read_to_string(&input).unwrap_or_else(|e| {
|
||||
let contents = match (file, raw) {
|
||||
(Some(input), None) => std::fs::read_to_string(&input).unwrap_or_else(|e| {
|
||||
log::error!("Cloud not read input file: {}.", e);
|
||||
exit(0);
|
||||
}),
|
||||
None => {
|
||||
(None, Some(raw)) => raw,
|
||||
(Some(_), Some(_)) => {
|
||||
log::error!("Only one of --file or --raw can be specified.");
|
||||
exit(0);
|
||||
}
|
||||
(None, None) => {
|
||||
if atty::is(atty::Stream::Stdin) {
|
||||
log::error!("No input file, source, or stdin to translate from.");
|
||||
exit(0);
|
||||
|
@ -67,7 +77,11 @@ impl Translate {
|
|||
}
|
||||
|
||||
/// render without handling svgs or anything
|
||||
fn simple_render_child(f: &mut impl std::fmt::Write, child: &Node, il: u32) -> std::fmt::Result {
|
||||
pub fn simple_render_child(
|
||||
f: &mut impl std::fmt::Write,
|
||||
child: &Node,
|
||||
il: u32,
|
||||
) -> std::fmt::Result {
|
||||
write_tabs(f, il)?;
|
||||
match child {
|
||||
Node::Text(t) => writeln!(f, "\"{}\"", t)?,
|
||||
|
|
|
@ -1,32 +1,48 @@
|
|||
<section class="text-gray-600 body-font">
|
||||
<div class="container px-5 py-24 mx-auto">
|
||||
<div class="flex flex-wrap -mx-4 -mb-10 text-center">
|
||||
<div class="sm:w-1/2 mb-10 px-4">
|
||||
<div class="rounded-lg h-64 overflow-hidden">
|
||||
<img alt="content" class="object-cover object-center h-full w-full"
|
||||
src="https://dummyimage.com/1201x501">
|
||||
</div>
|
||||
<h2 class="title-font text-2xl font-medium text-gray-900 mt-6 mb-3">Buy YouTube Videos</h2>
|
||||
<p class="leading-relaxed text-base">
|
||||
Williamsburg occupy sustainable snackwave gochujang. Pinterest cornhole brunch, slow-carb neutra
|
||||
irony.
|
||||
</p>
|
||||
<button
|
||||
class="flex mx-auto mt-6 text-white bg-indigo-500 border-0 py-2 px-5 focus:outline-none hover:bg-indigo-600 rounded">Button</button>
|
||||
</div>
|
||||
<div class="sm:w-1/2 mb-10 px-4">
|
||||
<div class="rounded-lg h-64 overflow-hidden">
|
||||
<img alt="content" class="object-cover object-center h-full w-full"
|
||||
src="https://dummyimage.com/1202x502">
|
||||
</div>
|
||||
<h2 class="title-font text-2xl font-medium text-gray-900 mt-6 mb-3">The Catalyzer</h2>
|
||||
<p class="leading-relaxed text-base">
|
||||
Williamsburg occupy sustainable snackwave gochujang. Pinterest
|
||||
cornhole brunch, slow-carb neutra irony.
|
||||
</p>
|
||||
<button
|
||||
class="flex mx-auto mt-6 text-white bg-indigo-500 border-0 py-2 px-5 focus:outline-none hover:bg-indigo-600 rounded">Button</button>
|
||||
</div>
|
||||
<div class="container px-5 py-24 mx-auto">
|
||||
<div class="flex flex-wrap -mx-4 -mb-10 text-center">
|
||||
<div class="sm:w-1/2 mb-10 px-4">
|
||||
<div class="rounded-lg h-64 overflow-hidden">
|
||||
<img
|
||||
alt="content"
|
||||
class="object-cover object-center h-full w-full"
|
||||
src="https://dummyimage.com/1201x501"
|
||||
/>
|
||||
</div>
|
||||
<h2 class="title-font text-2xl font-medium text-gray-900 mt-6 mb-3">
|
||||
Buy YouTube Videos
|
||||
</h2>
|
||||
<p class="leading-relaxed text-base">
|
||||
Williamsburg occupy sustainable snackwave gochujang. Pinterest
|
||||
cornhole brunch, slow-carb neutra irony.
|
||||
</p>
|
||||
<button
|
||||
class="flex mx-auto mt-6 text-white bg-indigo-500 border-0 py-2 px-5 focus:outline-none hover:bg-indigo-600 rounded"
|
||||
>
|
||||
Button
|
||||
</button>
|
||||
</div>
|
||||
<div class="sm:w-1/2 mb-10 px-4">
|
||||
<div class="rounded-lg h-64 overflow-hidden">
|
||||
<img
|
||||
alt="content"
|
||||
class="object-cover object-center h-full w-full"
|
||||
src="https://dummyimage.com/1202x502"
|
||||
/>
|
||||
</div>
|
||||
<h2 class="title-font text-2xl font-medium text-gray-900 mt-6 mb-3">
|
||||
The Catalyzer
|
||||
</h2>
|
||||
<p class="leading-relaxed text-base">
|
||||
Williamsburg occupy sustainable snackwave gochujang. Pinterest
|
||||
cornhole brunch, slow-carb neutra irony.
|
||||
</p>
|
||||
<button
|
||||
class="flex mx-auto mt-6 text-white bg-indigo-500 border-0 py-2 px-5 focus:outline-none hover:bg-indigo-600 rounded"
|
||||
>
|
||||
Button
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
|
Loading…
Reference in a new issue